std: Remove format_strbuf!()
This was only ever a transitionary macro.
This commit is contained in:
parent
24b1ce1daf
commit
42aed6bde2
@ -188,41 +188,41 @@ pub fn parse_config(args: Vec<String> ) -> Config {
|
||||
|
||||
pub fn log_config(config: &Config) {
|
||||
let c = config;
|
||||
logv(c, format_strbuf!("configuration:"));
|
||||
logv(c, format_strbuf!("compile_lib_path: {}", config.compile_lib_path));
|
||||
logv(c, format_strbuf!("run_lib_path: {}", config.run_lib_path));
|
||||
logv(c, format_strbuf!("rustc_path: {}", config.rustc_path.display()));
|
||||
logv(c, format_strbuf!("src_base: {}", config.src_base.display()));
|
||||
logv(c, format_strbuf!("build_base: {}", config.build_base.display()));
|
||||
logv(c, format_strbuf!("stage_id: {}", config.stage_id));
|
||||
logv(c, format_strbuf!("mode: {}", config.mode));
|
||||
logv(c, format_strbuf!("run_ignored: {}", config.run_ignored));
|
||||
logv(c, format_strbuf!("filter: {}",
|
||||
opt_str(&config.filter
|
||||
.as_ref()
|
||||
.map(|re| {
|
||||
re.to_str().into_string()
|
||||
}))));
|
||||
logv(c, format_strbuf!("runtool: {}", opt_str(&config.runtool)));
|
||||
logv(c, format_strbuf!("host-rustcflags: {}",
|
||||
opt_str(&config.host_rustcflags)));
|
||||
logv(c, format_strbuf!("target-rustcflags: {}",
|
||||
opt_str(&config.target_rustcflags)));
|
||||
logv(c, format_strbuf!("jit: {}", config.jit));
|
||||
logv(c, format_strbuf!("target: {}", config.target));
|
||||
logv(c, format_strbuf!("host: {}", config.host));
|
||||
logv(c, format_strbuf!("android-cross-path: {}",
|
||||
config.android_cross_path.display()));
|
||||
logv(c, format_strbuf!("adb_path: {}", config.adb_path));
|
||||
logv(c, format_strbuf!("adb_test_dir: {}", config.adb_test_dir));
|
||||
logv(c, format_strbuf!("adb_device_status: {}",
|
||||
config.adb_device_status));
|
||||
logv(c, format!("configuration:"));
|
||||
logv(c, format!("compile_lib_path: {}", config.compile_lib_path));
|
||||
logv(c, format!("run_lib_path: {}", config.run_lib_path));
|
||||
logv(c, format!("rustc_path: {}", config.rustc_path.display()));
|
||||
logv(c, format!("src_base: {}", config.src_base.display()));
|
||||
logv(c, format!("build_base: {}", config.build_base.display()));
|
||||
logv(c, format!("stage_id: {}", config.stage_id));
|
||||
logv(c, format!("mode: {}", config.mode));
|
||||
logv(c, format!("run_ignored: {}", config.run_ignored));
|
||||
logv(c, format!("filter: {}",
|
||||
opt_str(&config.filter
|
||||
.as_ref()
|
||||
.map(|re| {
|
||||
re.to_str().into_string()
|
||||
}))));
|
||||
logv(c, format!("runtool: {}", opt_str(&config.runtool)));
|
||||
logv(c, format!("host-rustcflags: {}",
|
||||
opt_str(&config.host_rustcflags)));
|
||||
logv(c, format!("target-rustcflags: {}",
|
||||
opt_str(&config.target_rustcflags)));
|
||||
logv(c, format!("jit: {}", config.jit));
|
||||
logv(c, format!("target: {}", config.target));
|
||||
logv(c, format!("host: {}", config.host));
|
||||
logv(c, format!("android-cross-path: {}",
|
||||
config.android_cross_path.display()));
|
||||
logv(c, format!("adb_path: {}", config.adb_path));
|
||||
logv(c, format!("adb_test_dir: {}", config.adb_test_dir));
|
||||
logv(c, format!("adb_device_status: {}",
|
||||
config.adb_device_status));
|
||||
match config.test_shard {
|
||||
None => logv(c, "test_shard: (all)".to_string()),
|
||||
Some((a,b)) => logv(c, format_strbuf!("test_shard: {}.{}", a, b))
|
||||
Some((a,b)) => logv(c, format!("test_shard: {}.{}", a, b))
|
||||
}
|
||||
logv(c, format_strbuf!("verbose: {}", config.verbose));
|
||||
logv(c, format_strbuf!("\n"));
|
||||
logv(c, format!("verbose: {}", config.verbose));
|
||||
logv(c, format!("\n"));
|
||||
}
|
||||
|
||||
pub fn opt_str<'a>(maybestr: &'a Option<String>) -> &'a str {
|
||||
@ -356,12 +356,10 @@ pub fn make_test_name(config: &Config, testfile: &Path) -> test::TestName {
|
||||
let filename = path.filename_str();
|
||||
let p = path.dir_path();
|
||||
let dir = p.filename_str();
|
||||
format_strbuf!("{}/{}", dir.unwrap_or(""), filename.unwrap_or(""))
|
||||
format!("{}/{}", dir.unwrap_or(""), filename.unwrap_or(""))
|
||||
}
|
||||
|
||||
test::DynTestName(format_strbuf!("[{}] {}",
|
||||
config.mode,
|
||||
shorten(testfile)))
|
||||
test::DynTestName(format!("[{}] {}", config.mode, shorten(testfile)))
|
||||
}
|
||||
|
||||
pub fn make_test_closure(config: &Config, testfile: &Path) -> test::TestFn {
|
||||
|
@ -120,11 +120,11 @@ pub fn load_props(testfile: &Path) -> TestProps {
|
||||
|
||||
pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
|
||||
fn ignore_target(config: &Config) -> String {
|
||||
format_strbuf!("ignore-{}", util::get_os(config.target.as_slice()))
|
||||
format!("ignore-{}", util::get_os(config.target.as_slice()))
|
||||
}
|
||||
fn ignore_stage(config: &Config) -> String {
|
||||
format_strbuf!("ignore-{}",
|
||||
config.stage_id.as_slice().split('-').next().unwrap())
|
||||
format!("ignore-{}",
|
||||
config.stage_id.as_slice().split('-').next().unwrap())
|
||||
}
|
||||
|
||||
let val = iter_header(testfile, |ln| {
|
||||
@ -243,7 +243,7 @@ fn parse_name_directive(line: &str, directive: &str) -> bool {
|
||||
|
||||
pub fn parse_name_value_directive(line: &str, directive: String)
|
||||
-> Option<String> {
|
||||
let keycolon = format_strbuf!("{}:", directive);
|
||||
let keycolon = format!("{}:", directive);
|
||||
match line.find_str(keycolon.as_slice()) {
|
||||
Some(colon) => {
|
||||
let value = line.slice(colon + keycolon.len(),
|
||||
|
@ -121,8 +121,7 @@ fn check_correct_failure_status(proc_res: &ProcRes) {
|
||||
static RUST_ERR: int = 101;
|
||||
if !proc_res.status.matches_exit_status(RUST_ERR) {
|
||||
fatal_ProcRes(
|
||||
format_strbuf!("failure produced the wrong error: {}",
|
||||
proc_res.status),
|
||||
format!("failure produced the wrong error: {}", proc_res.status),
|
||||
proc_res);
|
||||
}
|
||||
}
|
||||
@ -165,7 +164,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
|
||||
let mut round = 0;
|
||||
while round < rounds {
|
||||
logv(config, format_strbuf!("pretty-printing round {}", round));
|
||||
logv(config, format!("pretty-printing round {}", round));
|
||||
let proc_res = print_source(config,
|
||||
props,
|
||||
testfile,
|
||||
@ -173,8 +172,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
"normal");
|
||||
|
||||
if !proc_res.status.success() {
|
||||
fatal_ProcRes(format_strbuf!("pretty-printing failed in round {}",
|
||||
round),
|
||||
fatal_ProcRes(format!("pretty-printing failed in round {}", round),
|
||||
&proc_res);
|
||||
}
|
||||
|
||||
@ -214,15 +212,14 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
// additionally, run `--pretty expanded` and try to build it.
|
||||
let proc_res = print_source(config, props, testfile, (*srcs.get(round)).clone(), "expanded");
|
||||
if !proc_res.status.success() {
|
||||
fatal_ProcRes(format_strbuf!("pretty-printing (expanded) failed"),
|
||||
&proc_res);
|
||||
fatal_ProcRes(format!("pretty-printing (expanded) failed"), &proc_res);
|
||||
}
|
||||
|
||||
let ProcRes{ stdout: expanded_src, .. } = proc_res;
|
||||
let proc_res = typecheck_source(config, props, testfile, expanded_src);
|
||||
if !proc_res.status.success() {
|
||||
fatal_ProcRes(format_strbuf!("pretty-printed source (expanded) does \
|
||||
not typecheck"),
|
||||
fatal_ProcRes(format!("pretty-printed source (expanded) does \
|
||||
not typecheck"),
|
||||
&proc_res);
|
||||
}
|
||||
|
||||
@ -253,7 +250,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
let mut args = vec!("-".to_string(),
|
||||
"--pretty".to_string(),
|
||||
pretty_type,
|
||||
format_strbuf!("--target={}", config.target),
|
||||
format!("--target={}", config.target),
|
||||
"-L".to_string(),
|
||||
aux_dir.as_str().unwrap().to_string());
|
||||
args.push_all_move(split_maybe_args(&config.target_rustcflags));
|
||||
@ -300,7 +297,7 @@ actual:\n\
|
||||
let mut args = vec!("-".to_string(),
|
||||
"--no-trans".to_string(),
|
||||
"--crate-type=lib".to_string(),
|
||||
format_strbuf!("--target={}", target),
|
||||
format!("--target={}", target),
|
||||
"-L".to_string(),
|
||||
config.build_base.as_str().unwrap().to_string(),
|
||||
"-L".to_string(),
|
||||
@ -343,10 +340,8 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
|
||||
// write debugger script
|
||||
let script_str = ["set charset UTF-8".to_string(),
|
||||
format_strbuf!("file {}",
|
||||
exe_file.as_str()
|
||||
.unwrap()
|
||||
.to_string()),
|
||||
format!("file {}", exe_file.as_str().unwrap()
|
||||
.to_string()),
|
||||
"target remote :5039".to_string(),
|
||||
cmds,
|
||||
"quit".to_string()].connect("\n");
|
||||
@ -366,8 +361,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
],
|
||||
vec!(("".to_string(), "".to_string())),
|
||||
Some("".to_string()))
|
||||
.expect(format_strbuf!("failed to exec `{}`",
|
||||
config.adb_path));
|
||||
.expect(format!("failed to exec `{}`", config.adb_path));
|
||||
|
||||
procsrv::run("",
|
||||
config.adb_path.as_slice(),
|
||||
@ -378,15 +372,15 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
],
|
||||
vec!(("".to_string(), "".to_string())),
|
||||
Some("".to_string()))
|
||||
.expect(format_strbuf!("failed to exec `{}`", config.adb_path));
|
||||
.expect(format!("failed to exec `{}`", config.adb_path));
|
||||
|
||||
let adb_arg = format_strbuf!("export LD_LIBRARY_PATH={}; \
|
||||
gdbserver :5039 {}/{}",
|
||||
config.adb_test_dir.clone(),
|
||||
config.adb_test_dir.clone(),
|
||||
str::from_utf8(
|
||||
exe_file.filename()
|
||||
.unwrap()).unwrap());
|
||||
let adb_arg = format!("export LD_LIBRARY_PATH={}; \
|
||||
gdbserver :5039 {}/{}",
|
||||
config.adb_test_dir.clone(),
|
||||
config.adb_test_dir.clone(),
|
||||
str::from_utf8(
|
||||
exe_file.filename()
|
||||
.unwrap()).unwrap());
|
||||
|
||||
let mut process = procsrv::run_background("",
|
||||
config.adb_path
|
||||
@ -398,8 +392,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
vec!(("".to_string(),
|
||||
"".to_string())),
|
||||
Some("".to_string()))
|
||||
.expect(format_strbuf!("failed to exec `{}`",
|
||||
config.adb_path));
|
||||
.expect(format!("failed to exec `{}`", config.adb_path));
|
||||
loop {
|
||||
//waiting 1 second for gdbserver start
|
||||
timer::sleep(1000);
|
||||
@ -423,8 +416,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
vec!("-quiet".to_string(),
|
||||
"-batch".to_string(),
|
||||
"-nx".to_string(),
|
||||
format_strbuf!("-command={}",
|
||||
debugger_script.as_str().unwrap()));
|
||||
format!("-command={}", debugger_script.as_str().unwrap()));
|
||||
|
||||
let gdb_path = tool_path.append("/bin/arm-linux-androideabi-gdb");
|
||||
let procsrv::Result {
|
||||
@ -436,12 +428,12 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
debugger_opts.as_slice(),
|
||||
vec!(("".to_string(), "".to_string())),
|
||||
None)
|
||||
.expect(format_strbuf!("failed to exec `{}`", gdb_path));
|
||||
.expect(format!("failed to exec `{}`", gdb_path));
|
||||
let cmdline = {
|
||||
let cmdline = make_cmdline("",
|
||||
"arm-linux-androideabi-gdb",
|
||||
debugger_opts.as_slice());
|
||||
logv(config, format_strbuf!("executing {}", cmdline));
|
||||
logv(config, format!("executing {}", cmdline));
|
||||
cmdline
|
||||
};
|
||||
|
||||
@ -484,8 +476,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
vec!("-quiet".to_string(),
|
||||
"-batch".to_string(),
|
||||
"-nx".to_string(),
|
||||
format_strbuf!("-command={}",
|
||||
debugger_script.as_str().unwrap()),
|
||||
format!("-command={}", debugger_script.as_str().unwrap()),
|
||||
exe_file.as_str().unwrap().to_string());
|
||||
proc_args = ProcArgs {
|
||||
prog: debugger(),
|
||||
@ -593,9 +584,8 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
|
||||
str::from_utf8(error.as_slice()).unwrap().to_string())
|
||||
},
|
||||
Err(e) => {
|
||||
fatal(format_strbuf!("Failed to setup Python process for \
|
||||
LLDB script: {}",
|
||||
e))
|
||||
fatal(format!("Failed to setup Python process for \
|
||||
LLDB script: {}", e))
|
||||
}
|
||||
};
|
||||
|
||||
@ -604,7 +594,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
|
||||
status: status,
|
||||
stdout: out,
|
||||
stderr: err,
|
||||
cmdline: format_strbuf!("{}", cmd)
|
||||
cmdline: format!("{}", cmd)
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -647,9 +637,7 @@ fn parse_debugger_commands(file_path: &Path, debugger_prefix: &str)
|
||||
});
|
||||
}
|
||||
Err(e) => {
|
||||
fatal(format_strbuf!("Error while parsing debugger commands: \
|
||||
{}",
|
||||
e))
|
||||
fatal(format!("Error while parsing debugger commands: {}", e))
|
||||
}
|
||||
}
|
||||
counter += 1;
|
||||
@ -732,9 +720,8 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
|
||||
}
|
||||
}
|
||||
if i != num_check_lines {
|
||||
fatal_ProcRes(format_strbuf!("line not found in debugger output: \
|
||||
{}",
|
||||
check_lines.get(i).unwrap()),
|
||||
fatal_ProcRes(format!("line not found in debugger output: {}",
|
||||
check_lines.get(i).unwrap()),
|
||||
debugger_run_result);
|
||||
}
|
||||
}
|
||||
@ -744,8 +731,8 @@ fn check_error_patterns(props: &TestProps,
|
||||
testfile: &Path,
|
||||
proc_res: &ProcRes) {
|
||||
if props.error_patterns.is_empty() {
|
||||
fatal(format_strbuf!("no error pattern specified in {}",
|
||||
testfile.display().as_maybe_owned().as_slice()));
|
||||
fatal(format!("no error pattern specified in {}",
|
||||
testfile.display().as_maybe_owned().as_slice()));
|
||||
}
|
||||
|
||||
if proc_res.status.success() {
|
||||
@ -756,7 +743,7 @@ fn check_error_patterns(props: &TestProps,
|
||||
let mut next_err_pat = props.error_patterns.get(next_err_idx);
|
||||
let mut done = false;
|
||||
let output_to_check = if props.check_stdout {
|
||||
format_strbuf!("{}{}", proc_res.stdout, proc_res.stderr)
|
||||
format!("{}{}", proc_res.stdout, proc_res.stderr)
|
||||
} else {
|
||||
proc_res.stderr.clone()
|
||||
};
|
||||
@ -777,12 +764,12 @@ fn check_error_patterns(props: &TestProps,
|
||||
let missing_patterns =
|
||||
props.error_patterns.slice(next_err_idx, props.error_patterns.len());
|
||||
if missing_patterns.len() == 1u {
|
||||
fatal_ProcRes(format_strbuf!("error pattern '{}' not found!",
|
||||
missing_patterns[0]),
|
||||
fatal_ProcRes(format!("error pattern '{}' not found!",
|
||||
missing_patterns[0]),
|
||||
proc_res);
|
||||
} else {
|
||||
for pattern in missing_patterns.iter() {
|
||||
error(format_strbuf!("error pattern '{}' not found!", *pattern));
|
||||
error(format!("error pattern '{}' not found!", *pattern));
|
||||
}
|
||||
fatal_ProcRes("multiple error patterns not found".to_string(),
|
||||
proc_res);
|
||||
@ -811,7 +798,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
|
||||
}
|
||||
|
||||
let prefixes = expected_errors.iter().map(|ee| {
|
||||
format_strbuf!("{}:{}:", testfile.display(), ee.line)
|
||||
format!("{}:{}:", testfile.display(), ee.line)
|
||||
}).collect::<Vec<String> >();
|
||||
|
||||
#[cfg(target_os = "win32")]
|
||||
@ -870,9 +857,8 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
|
||||
}
|
||||
|
||||
if !was_expected && is_compiler_error_or_warning(line) {
|
||||
fatal_ProcRes(format_strbuf!("unexpected compiler error or \
|
||||
warning: '{}'",
|
||||
line),
|
||||
fatal_ProcRes(format!("unexpected compiler error or warning: '{}'",
|
||||
line),
|
||||
proc_res);
|
||||
}
|
||||
}
|
||||
@ -880,11 +866,8 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
|
||||
for (i, &flag) in found_flags.iter().enumerate() {
|
||||
if !flag {
|
||||
let ee = expected_errors.get(i);
|
||||
fatal_ProcRes(format_strbuf!("expected {} on line {} not found: \
|
||||
{}",
|
||||
ee.kind,
|
||||
ee.line,
|
||||
ee.msg),
|
||||
fatal_ProcRes(format!("expected {} on line {} not found: {}",
|
||||
ee.kind, ee.line, ee.msg),
|
||||
proc_res);
|
||||
}
|
||||
}
|
||||
@ -1065,8 +1048,8 @@ fn compose_and_run_compiler(
|
||||
None);
|
||||
if !auxres.status.success() {
|
||||
fatal_ProcRes(
|
||||
format_strbuf!("auxiliary build of {} failed to compile: ",
|
||||
abs_ab.display()),
|
||||
format!("auxiliary build of {} failed to compile: ",
|
||||
abs_ab.display()),
|
||||
&auxres);
|
||||
}
|
||||
|
||||
@ -1121,7 +1104,7 @@ fn make_compile_args(config: &Config,
|
||||
let mut args = vec!(testfile.as_str().unwrap().to_string(),
|
||||
"-L".to_string(),
|
||||
config.build_base.as_str().unwrap().to_string(),
|
||||
format_strbuf!("--target={}", target));
|
||||
format!("--target={}", target));
|
||||
args.push_all(extras.as_slice());
|
||||
if !props.no_prefer_dynamic {
|
||||
args.push("-C".to_string());
|
||||
@ -1213,7 +1196,7 @@ fn program_output(config: &Config, testfile: &Path, lib_path: &str, prog: String
|
||||
let cmdline = make_cmdline(lib_path,
|
||||
prog.as_slice(),
|
||||
args.as_slice());
|
||||
logv(config, format_strbuf!("executing {}", cmdline));
|
||||
logv(config, format!("executing {}", cmdline));
|
||||
cmdline
|
||||
};
|
||||
let procsrv::Result {
|
||||
@ -1224,8 +1207,7 @@ fn program_output(config: &Config, testfile: &Path, lib_path: &str, prog: String
|
||||
prog.as_slice(),
|
||||
args.as_slice(),
|
||||
env,
|
||||
input).expect(format_strbuf!("failed to exec `{}`",
|
||||
prog));
|
||||
input).expect(format!("failed to exec `{}`", prog));
|
||||
dump_output(config, testfile, out.as_slice(), err.as_slice());
|
||||
return ProcRes {
|
||||
status: status,
|
||||
@ -1240,24 +1222,19 @@ fn program_output(config: &Config, testfile: &Path, lib_path: &str, prog: String
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_os = "freebsd")]
|
||||
fn make_cmdline(_libpath: &str, prog: &str, args: &[String]) -> String {
|
||||
format_strbuf!("{} {}", prog, args.connect(" "))
|
||||
format!("{} {}", prog, args.connect(" "))
|
||||
}
|
||||
|
||||
#[cfg(target_os = "win32")]
|
||||
fn make_cmdline(libpath: &str, prog: &str, args: &[String]) -> String {
|
||||
format_strbuf!("{} {} {}",
|
||||
lib_path_cmd_prefix(libpath),
|
||||
prog,
|
||||
args.connect(" "))
|
||||
format!("{} {} {}", lib_path_cmd_prefix(libpath), prog, args.connect(" "))
|
||||
}
|
||||
|
||||
// Build the LD_LIBRARY_PATH variable as it would be seen on the command line
|
||||
// for diagnostic purposes
|
||||
#[cfg(target_os = "win32")]
|
||||
fn lib_path_cmd_prefix(path: &str) -> String {
|
||||
format_strbuf!("{}=\"{}\"",
|
||||
util::lib_path_env_var(),
|
||||
util::make_new_path(path))
|
||||
format!("{}=\"{}\"", util::lib_path_env_var(), util::make_new_path(path))
|
||||
}
|
||||
|
||||
fn dump_output(config: &Config, testfile: &Path, out: &str, err: &str) {
|
||||
@ -1356,7 +1333,7 @@ fn _arm_exec_compiled_test(config: &Config,
|
||||
],
|
||||
vec!(("".to_string(), "".to_string())),
|
||||
Some("".to_string()))
|
||||
.expect(format_strbuf!("failed to exec `{}`", config.adb_path));
|
||||
.expect(format!("failed to exec `{}`", config.adb_path));
|
||||
|
||||
if config.verbose {
|
||||
println!("push ({}) {} {} {}",
|
||||
@ -1366,19 +1343,18 @@ fn _arm_exec_compiled_test(config: &Config,
|
||||
copy_result.err);
|
||||
}
|
||||
|
||||
logv(config, format_strbuf!("executing ({}) {}", config.target, cmdline));
|
||||
logv(config, format!("executing ({}) {}", config.target, cmdline));
|
||||
|
||||
let mut runargs = Vec::new();
|
||||
|
||||
// run test via adb_run_wrapper
|
||||
runargs.push("shell".to_string());
|
||||
for (key, val) in env.move_iter() {
|
||||
runargs.push(format_strbuf!("{}={}", key, val));
|
||||
runargs.push(format!("{}={}", key, val));
|
||||
}
|
||||
runargs.push(format_strbuf!("{}/adb_run_wrapper.sh",
|
||||
config.adb_test_dir));
|
||||
runargs.push(format_strbuf!("{}", config.adb_test_dir));
|
||||
runargs.push(format_strbuf!("{}", prog_short));
|
||||
runargs.push(format!("{}/adb_run_wrapper.sh", config.adb_test_dir));
|
||||
runargs.push(format!("{}", config.adb_test_dir));
|
||||
runargs.push(format!("{}", prog_short));
|
||||
|
||||
for tv in args.args.iter() {
|
||||
runargs.push(tv.to_string());
|
||||
@ -1387,15 +1363,13 @@ fn _arm_exec_compiled_test(config: &Config,
|
||||
config.adb_path.as_slice(),
|
||||
runargs.as_slice(),
|
||||
vec!(("".to_string(), "".to_string())), Some("".to_string()))
|
||||
.expect(format_strbuf!("failed to exec `{}`", config.adb_path));
|
||||
.expect(format!("failed to exec `{}`", config.adb_path));
|
||||
|
||||
// get exitcode of result
|
||||
runargs = Vec::new();
|
||||
runargs.push("shell".to_string());
|
||||
runargs.push("cat".to_string());
|
||||
runargs.push(format_strbuf!("{}/{}.exitcode",
|
||||
config.adb_test_dir,
|
||||
prog_short));
|
||||
runargs.push(format!("{}/{}.exitcode", config.adb_test_dir, prog_short));
|
||||
|
||||
let procsrv::Result{ out: exitcode_out, err: _, status: _ } =
|
||||
procsrv::run("",
|
||||
@ -1403,7 +1377,7 @@ fn _arm_exec_compiled_test(config: &Config,
|
||||
runargs.as_slice(),
|
||||
vec!(("".to_string(), "".to_string())),
|
||||
Some("".to_string()))
|
||||
.expect(format_strbuf!("failed to exec `{}`", config.adb_path));
|
||||
.expect(format!("failed to exec `{}`", config.adb_path));
|
||||
|
||||
let mut exitcode: int = 0;
|
||||
for c in exitcode_out.as_slice().chars() {
|
||||
@ -1418,9 +1392,7 @@ fn _arm_exec_compiled_test(config: &Config,
|
||||
runargs = Vec::new();
|
||||
runargs.push("shell".to_string());
|
||||
runargs.push("cat".to_string());
|
||||
runargs.push(format_strbuf!("{}/{}.stdout",
|
||||
config.adb_test_dir,
|
||||
prog_short));
|
||||
runargs.push(format!("{}/{}.stdout", config.adb_test_dir, prog_short));
|
||||
|
||||
let procsrv::Result{ out: stdout_out, err: _, status: _ } =
|
||||
procsrv::run("",
|
||||
@ -1428,15 +1400,13 @@ fn _arm_exec_compiled_test(config: &Config,
|
||||
runargs.as_slice(),
|
||||
vec!(("".to_string(), "".to_string())),
|
||||
Some("".to_string()))
|
||||
.expect(format_strbuf!("failed to exec `{}`", config.adb_path));
|
||||
.expect(format!("failed to exec `{}`", config.adb_path));
|
||||
|
||||
// get stderr of result
|
||||
runargs = Vec::new();
|
||||
runargs.push("shell".to_string());
|
||||
runargs.push("cat".to_string());
|
||||
runargs.push(format_strbuf!("{}/{}.stderr",
|
||||
config.adb_test_dir,
|
||||
prog_short));
|
||||
runargs.push(format!("{}/{}.stderr", config.adb_test_dir, prog_short));
|
||||
|
||||
let procsrv::Result{ out: stderr_out, err: _, status: _ } =
|
||||
procsrv::run("",
|
||||
@ -1444,7 +1414,7 @@ fn _arm_exec_compiled_test(config: &Config,
|
||||
runargs.as_slice(),
|
||||
vec!(("".to_string(), "".to_string())),
|
||||
Some("".to_string()))
|
||||
.expect(format_strbuf!("failed to exec `{}`", config.adb_path));
|
||||
.expect(format!("failed to exec `{}`", config.adb_path));
|
||||
|
||||
dump_output(config,
|
||||
testfile,
|
||||
@ -1478,8 +1448,7 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
|
||||
vec!(("".to_string(),
|
||||
"".to_string())),
|
||||
Some("".to_string()))
|
||||
.expect(format_strbuf!("failed to exec `{}`",
|
||||
config.adb_path));
|
||||
.expect(format!("failed to exec `{}`", config.adb_path));
|
||||
|
||||
if config.verbose {
|
||||
println!("push ({}) {} {} {}",
|
||||
@ -1549,8 +1518,8 @@ fn extract_function_from_bitcode(config: &Config, _props: &TestProps,
|
||||
let proc_args = ProcArgs {
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
prog: prog.as_str().unwrap().to_string(),
|
||||
args: vec!(format_strbuf!("-func={}", fname),
|
||||
format_strbuf!("-o={}", extracted_bc.as_str().unwrap()),
|
||||
args: vec!(format!("-func={}", fname),
|
||||
format!("-o={}", extracted_bc.as_str().unwrap()),
|
||||
bitcodefile.as_str().unwrap().to_string())
|
||||
};
|
||||
compose_and_run(config, testfile, proc_args, Vec::new(), "", None)
|
||||
@ -1566,7 +1535,7 @@ fn disassemble_extract(config: &Config, _props: &TestProps,
|
||||
let proc_args = ProcArgs {
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
prog: prog.as_str().unwrap().to_string(),
|
||||
args: vec!(format_strbuf!("-o={}", extracted_ll.as_str().unwrap()),
|
||||
args: vec!(format!("-o={}", extracted_ll.as_str().unwrap()),
|
||||
extracted_bc.as_str().unwrap().to_string())
|
||||
};
|
||||
compose_and_run(config, testfile, proc_args, Vec::new(), "", None)
|
||||
|
@ -39,7 +39,7 @@ pub fn make_new_path(path: &str) -> String {
|
||||
// maintain the current value while adding our own
|
||||
match getenv(lib_path_env_var().as_slice()) {
|
||||
Some(curr) => {
|
||||
format_strbuf!("{}{}{}", path, path_div(), curr)
|
||||
format!("{}{}{}", path, path_div(), curr)
|
||||
}
|
||||
None => path.to_str().to_string()
|
||||
}
|
||||
|
@ -23,14 +23,14 @@ let y: int = x.unwrap();
|
||||
|
||||
**Int to string, in non-base-10**
|
||||
|
||||
Use the `format_strbuf!` syntax extension.
|
||||
Use the `format!` syntax extension.
|
||||
|
||||
~~~
|
||||
let x: int = 42;
|
||||
let y: String = format_strbuf!("{:t}", x); // binary
|
||||
let y: String = format_strbuf!("{:o}", x); // octal
|
||||
let y: String = format_strbuf!("{:x}", x); // lowercase hexadecimal
|
||||
let y: String = format_strbuf!("{:X}", x); // uppercase hexadecimal
|
||||
let y: String = format!("{:t}", x); // binary
|
||||
let y: String = format!("{:o}", x); // octal
|
||||
let y: String = format!("{:x}", x); // lowercase hexadecimal
|
||||
let y: String = format!("{:X}", x); // uppercase hexadecimal
|
||||
~~~
|
||||
|
||||
**String to int, in non-base-10**
|
||||
|
@ -500,19 +500,19 @@ impl Fail_ {
|
||||
pub fn to_err_msg(self) -> String {
|
||||
match self {
|
||||
ArgumentMissing(ref nm) => {
|
||||
format_strbuf!("Argument to option '{}' missing.", *nm)
|
||||
format!("Argument to option '{}' missing.", *nm)
|
||||
}
|
||||
UnrecognizedOption(ref nm) => {
|
||||
format_strbuf!("Unrecognized option: '{}'.", *nm)
|
||||
format!("Unrecognized option: '{}'.", *nm)
|
||||
}
|
||||
OptionMissing(ref nm) => {
|
||||
format_strbuf!("Required option '{}' missing.", *nm)
|
||||
format!("Required option '{}' missing.", *nm)
|
||||
}
|
||||
OptionDuplicated(ref nm) => {
|
||||
format_strbuf!("Option '{}' given more than once.", *nm)
|
||||
format!("Option '{}' given more than once.", *nm)
|
||||
}
|
||||
UnexpectedArgument(ref nm) => {
|
||||
format_strbuf!("Option '{}' does not take an argument.", *nm)
|
||||
format!("Option '{}' does not take an argument.", *nm)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -740,9 +740,8 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
|
||||
row
|
||||
});
|
||||
|
||||
format_strbuf!("{}\n\nOptions:\n{}\n",
|
||||
brief,
|
||||
rows.collect::<Vec<String>>().connect("\n"))
|
||||
format!("{}\n\nOptions:\n{}\n", brief,
|
||||
rows.collect::<Vec<String>>().connect("\n"))
|
||||
}
|
||||
|
||||
fn format_option(opt: &OptGroup) -> String {
|
||||
@ -784,7 +783,7 @@ fn format_option(opt: &OptGroup) -> String {
|
||||
|
||||
/// Derive a short one-line usage summary from a set of long options.
|
||||
pub fn short_usage(program_name: &str, opts: &[OptGroup]) -> String {
|
||||
let mut line = format_strbuf!("Usage: {} ", program_name);
|
||||
let mut line = format!("Usage: {} ", program_name);
|
||||
line.push_str(opts.iter()
|
||||
.map(format_option)
|
||||
.collect::<Vec<String>>()
|
||||
|
@ -1215,7 +1215,7 @@ impl ToStrRadix for BigInt {
|
||||
match self.sign {
|
||||
Plus => self.data.to_str_radix(radix),
|
||||
Zero => "0".to_string(),
|
||||
Minus => format_strbuf!("-{}", self.data.to_str_radix(radix)),
|
||||
Minus => format!("-{}", self.data.to_str_radix(radix)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2055,34 +2055,34 @@ mod biguint_tests {
|
||||
(16, "fff".to_string())
|
||||
)), ( BigUint::from_slice([ 1, 2 ]), vec!(
|
||||
(2,
|
||||
format_strbuf!("10{}1", "0".repeat(bits - 1))),
|
||||
format!("10{}1", "0".repeat(bits - 1))),
|
||||
(4,
|
||||
format_strbuf!("2{}1", "0".repeat(bits / 2 - 1))),
|
||||
format!("2{}1", "0".repeat(bits / 2 - 1))),
|
||||
(10, match bits {
|
||||
32 => "8589934593".to_string(),
|
||||
16 => "131073".to_string(),
|
||||
_ => fail!()
|
||||
}),
|
||||
(16,
|
||||
format_strbuf!("2{}1", "0".repeat(bits / 4 - 1)))
|
||||
format!("2{}1", "0".repeat(bits / 4 - 1)))
|
||||
)), ( BigUint::from_slice([ 1, 2, 3 ]), vec!(
|
||||
(2,
|
||||
format_strbuf!("11{}10{}1",
|
||||
"0".repeat(bits - 2),
|
||||
"0".repeat(bits - 1))),
|
||||
format!("11{}10{}1",
|
||||
"0".repeat(bits - 2),
|
||||
"0".repeat(bits - 1))),
|
||||
(4,
|
||||
format_strbuf!("3{}2{}1",
|
||||
"0".repeat(bits / 2 - 1),
|
||||
"0".repeat(bits / 2 - 1))),
|
||||
format!("3{}2{}1",
|
||||
"0".repeat(bits / 2 - 1),
|
||||
"0".repeat(bits / 2 - 1))),
|
||||
(10, match bits {
|
||||
32 => "55340232229718589441".to_string(),
|
||||
16 => "12885032961".to_string(),
|
||||
_ => fail!()
|
||||
}),
|
||||
(16,
|
||||
format_strbuf!("3{}2{}1",
|
||||
"0".repeat(bits / 4 - 1),
|
||||
"0".repeat(bits / 4 - 1)))
|
||||
format!("3{}2{}1",
|
||||
"0".repeat(bits / 4 - 1),
|
||||
"0".repeat(bits / 4 - 1)))
|
||||
)) )
|
||||
}
|
||||
|
||||
|
@ -177,13 +177,13 @@ impl<T: fmt::Show + Num + Ord> fmt::Show for Complex<T> {
|
||||
impl<T: ToStrRadix + Num + Ord> ToStrRadix for Complex<T> {
|
||||
fn to_str_radix(&self, radix: uint) -> String {
|
||||
if self.im < Zero::zero() {
|
||||
format_strbuf!("{}-{}i",
|
||||
self.re.to_str_radix(radix),
|
||||
(-self.im).to_str_radix(radix))
|
||||
format!("{}-{}i",
|
||||
self.re.to_str_radix(radix),
|
||||
(-self.im).to_str_radix(radix))
|
||||
} else {
|
||||
format_strbuf!("{}+{}i",
|
||||
self.re.to_str_radix(radix),
|
||||
self.im.to_str_radix(radix))
|
||||
format!("{}+{}i",
|
||||
self.re.to_str_radix(radix),
|
||||
self.im.to_str_radix(radix))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -282,9 +282,9 @@ impl<T: fmt::Show> fmt::Show for Ratio<T> {
|
||||
impl<T: ToStrRadix> ToStrRadix for Ratio<T> {
|
||||
/// Renders as `numer/denom` where the numbers are in base `radix`.
|
||||
fn to_str_radix(&self, radix: uint) -> String {
|
||||
format_strbuf!("{}/{}",
|
||||
self.numer.to_str_radix(radix),
|
||||
self.denom.to_str_radix(radix))
|
||||
format!("{}/{}",
|
||||
self.numer.to_str_radix(radix),
|
||||
self.denom.to_str_radix(radix))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,7 +425,7 @@ impl Regex {
|
||||
/// # use regex::Captures; fn main() {
|
||||
/// let re = regex!(r"([^,\s]+),\s+(\S+)");
|
||||
/// let result = re.replace("Springsteen, Bruce", |caps: &Captures| {
|
||||
/// format_strbuf!("{} {}", caps.at(2), caps.at(1))
|
||||
/// format!("{} {}", caps.at(2), caps.at(1))
|
||||
/// });
|
||||
/// assert_eq!(result.as_slice(), "Bruce Springsteen");
|
||||
/// # }
|
||||
@ -761,9 +761,8 @@ impl<'t> Captures<'t> {
|
||||
let re = Regex::new(r"(^|[^$]|\b)\$(\w+)").unwrap();
|
||||
let text = re.replace_all(text, |refs: &Captures| -> String {
|
||||
let (pre, name) = (refs.at(1), refs.at(2));
|
||||
format_strbuf!("{}{}",
|
||||
pre,
|
||||
match from_str::<uint>(name.as_slice()) {
|
||||
format!("{}{}", pre,
|
||||
match from_str::<uint>(name.as_slice()) {
|
||||
None => self.name(name).to_string(),
|
||||
Some(i) => self.at(i).to_string(),
|
||||
})
|
||||
|
@ -165,7 +165,7 @@ impl<'a> Archive<'a> {
|
||||
if skip.iter().any(|s| *s == filename) { continue }
|
||||
if filename.contains(".SYMDEF") { continue }
|
||||
|
||||
let filename = format_strbuf!("r-{}-{}", name, filename);
|
||||
let filename = format!("r-{}-{}", name, filename);
|
||||
let new_filename = file.with_filename(filename);
|
||||
try!(fs::rename(file, &new_filename));
|
||||
inputs.push(new_filename);
|
||||
@ -185,8 +185,8 @@ impl<'a> Archive<'a> {
|
||||
};
|
||||
// On Windows, static libraries sometimes show up as libfoo.a and other
|
||||
// times show up as foo.lib
|
||||
let oslibname = format_strbuf!("{}{}.{}", osprefix, name, osext);
|
||||
let unixlibname = format_strbuf!("lib{}.a", name);
|
||||
let oslibname = format!("{}{}.{}", osprefix, name, osext);
|
||||
let unixlibname = format!("lib{}.a", name);
|
||||
|
||||
let mut rustpath = filesearch::rust_path();
|
||||
rustpath.push(self.sess.target_filesearch().get_lib_path());
|
||||
|
@ -751,10 +751,7 @@ pub fn mangle_internal_name_by_path_and_seq(path: PathElems, flav: &str) -> Stri
|
||||
}
|
||||
|
||||
pub fn output_lib_filename(id: &CrateId) -> String {
|
||||
format_strbuf!("{}-{}-{}",
|
||||
id.name,
|
||||
crate_id_hash(id),
|
||||
id.version_or_default())
|
||||
format!("{}-{}-{}", id.name, crate_id_hash(id), id.version_or_default())
|
||||
}
|
||||
|
||||
pub fn get_cc_prog(sess: &Session) -> String {
|
||||
@ -827,7 +824,7 @@ pub fn filename_for_input(sess: &Session, crate_type: config::CrateType,
|
||||
let libname = output_lib_filename(id);
|
||||
match crate_type {
|
||||
config::CrateTypeRlib => {
|
||||
out_filename.with_filename(format_strbuf!("lib{}.rlib", libname))
|
||||
out_filename.with_filename(format!("lib{}.rlib", libname))
|
||||
}
|
||||
config::CrateTypeDylib => {
|
||||
let (prefix, suffix) = match sess.targ_cfg.os {
|
||||
@ -837,13 +834,11 @@ pub fn filename_for_input(sess: &Session, crate_type: config::CrateType,
|
||||
abi::OsAndroid => (loader::ANDROID_DLL_PREFIX, loader::ANDROID_DLL_SUFFIX),
|
||||
abi::OsFreebsd => (loader::FREEBSD_DLL_PREFIX, loader::FREEBSD_DLL_SUFFIX),
|
||||
};
|
||||
out_filename.with_filename(format_strbuf!("{}{}{}",
|
||||
prefix,
|
||||
libname,
|
||||
suffix))
|
||||
out_filename.with_filename(format!("{}{}{}", prefix, libname,
|
||||
suffix))
|
||||
}
|
||||
config::CrateTypeStaticlib => {
|
||||
out_filename.with_filename(format_strbuf!("lib{}.a", libname))
|
||||
out_filename.with_filename(format!("lib{}.a", libname))
|
||||
}
|
||||
config::CrateTypeExecutable => out_filename.clone(),
|
||||
}
|
||||
@ -1350,7 +1345,7 @@ fn add_local_native_libraries(cmd: &mut Command, sess: &Session) {
|
||||
cmd.arg("-Wl,-Bdynamic");
|
||||
}
|
||||
}
|
||||
cmd.arg(format_strbuf!("-l{}", *l));
|
||||
cmd.arg(format!("-l{}", *l));
|
||||
}
|
||||
cstore::NativeFramework => {
|
||||
cmd.arg("-framework");
|
||||
@ -1514,7 +1509,7 @@ fn add_upstream_native_libraries(cmd: &mut Command, sess: &Session) {
|
||||
for &(kind, ref lib) in libs.iter() {
|
||||
match kind {
|
||||
cstore::NativeUnknown => {
|
||||
cmd.arg(format_strbuf!("-l{}", *lib));
|
||||
cmd.arg(format!("-l{}", *lib));
|
||||
}
|
||||
cstore::NativeFramework => {
|
||||
cmd.arg("-framework");
|
||||
|
@ -85,8 +85,8 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
|
||||
ptr as *libc::c_char,
|
||||
bc.len() as libc::size_t) {
|
||||
link::llvm_err(sess,
|
||||
format_strbuf!("failed to load bc of `{}`",
|
||||
name.as_slice()));
|
||||
format!("failed to load bc of `{}`",
|
||||
name.as_slice()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -653,14 +653,14 @@ pub fn pretty_print_input(sess: Session,
|
||||
PpmFlowGraph(nodeid) => {
|
||||
let ast_map = ast_map.expect("--pretty flowgraph missing ast_map");
|
||||
let node = ast_map.find(nodeid).unwrap_or_else(|| {
|
||||
sess.fatal(format_strbuf!("--pretty flowgraph couldn't find id: {}",
|
||||
nodeid).as_slice())
|
||||
sess.fatal(format!("--pretty flowgraph couldn't find id: {}",
|
||||
nodeid).as_slice())
|
||||
});
|
||||
let block = match node {
|
||||
syntax::ast_map::NodeBlock(block) => block,
|
||||
_ => {
|
||||
let message = format_strbuf!("--pretty=flowgraph needs block, got {:?}",
|
||||
node);
|
||||
let message = format!("--pretty=flowgraph needs block, got {:?}",
|
||||
node);
|
||||
|
||||
// point to what was found, if there's an
|
||||
// accessible span.
|
||||
@ -706,7 +706,7 @@ fn print_flowgraph<W:io::Writer>(analysis: CrateAnalysis,
|
||||
io::IoError {
|
||||
detail: Some(match orig_detail {
|
||||
None => m.into_string(),
|
||||
Some(d) => format_strbuf!("{}: {}", m, d)
|
||||
Some(d) => format!("{}: {}", m, d)
|
||||
}),
|
||||
..ioerr
|
||||
}
|
||||
|
@ -1892,7 +1892,7 @@ impl TypeNames {
|
||||
|
||||
pub fn types_to_str(&self, tys: &[Type]) -> String {
|
||||
let strs: Vec<String> = tys.iter().map(|t| self.type_to_str(*t)).collect();
|
||||
format_strbuf!("[{}]", strs.connect(",").to_string())
|
||||
format!("[{}]", strs.connect(",").to_string())
|
||||
}
|
||||
|
||||
pub fn val_to_str(&self, val: ValueRef) -> String {
|
||||
|
@ -140,7 +140,7 @@ fn encode_family(ebml_w: &mut Encoder, c: char) {
|
||||
}
|
||||
|
||||
pub fn def_to_str(did: DefId) -> String {
|
||||
format_strbuf!("{}:{}", did.krate, did.node)
|
||||
format!("{}:{}", did.krate, did.node)
|
||||
}
|
||||
|
||||
fn encode_ty_type_param_defs(ebml_w: &mut Encoder,
|
||||
|
@ -506,7 +506,7 @@ fn get_metadata_section(os: Os, filename: &Path) -> Result<MetadataBlob, String>
|
||||
|
||||
fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, String> {
|
||||
if !filename.exists() {
|
||||
return Err(format_strbuf!("no such file: '{}'", filename.display()));
|
||||
return Err(format!("no such file: '{}'", filename.display()));
|
||||
}
|
||||
if filename.filename_str().unwrap().ends_with(".rlib") {
|
||||
// Use ArchiveRO for speed here, it's backed by LLVM and uses mmap
|
||||
@ -516,16 +516,14 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, Str
|
||||
Some(ar) => ar,
|
||||
None => {
|
||||
debug!("llvm didn't like `{}`", filename.display());
|
||||
return Err(format_strbuf!("failed to read rlib metadata: \
|
||||
'{}'",
|
||||
filename.display()));
|
||||
return Err(format!("failed to read rlib metadata: '{}'",
|
||||
filename.display()));
|
||||
}
|
||||
};
|
||||
return match ArchiveMetadata::new(archive).map(|ar| MetadataArchive(ar)) {
|
||||
None => {
|
||||
return Err((format_strbuf!("failed to read rlib metadata: \
|
||||
'{}'",
|
||||
filename.display())))
|
||||
return Err((format!("failed to read rlib metadata: '{}'",
|
||||
filename.display())))
|
||||
}
|
||||
Some(blob) => return Ok(blob)
|
||||
}
|
||||
@ -535,15 +533,14 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, Str
|
||||
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
|
||||
});
|
||||
if mb as int == 0 {
|
||||
return Err(format_strbuf!("error reading library: '{}'",
|
||||
filename.display()))
|
||||
return Err(format!("error reading library: '{}'",
|
||||
filename.display()))
|
||||
}
|
||||
let of = match ObjectFile::new(mb) {
|
||||
Some(of) => of,
|
||||
_ => {
|
||||
return Err((format_strbuf!("provided path not an object \
|
||||
file: '{}'",
|
||||
filename.display())))
|
||||
return Err((format!("provided path not an object file: '{}'",
|
||||
filename.display())))
|
||||
}
|
||||
};
|
||||
let si = mk_section_iter(of.llof);
|
||||
@ -556,8 +553,7 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, Str
|
||||
let cbuf = llvm::LLVMGetSectionContents(si.llsi);
|
||||
let csz = llvm::LLVMGetSectionSize(si.llsi) as uint;
|
||||
let mut found =
|
||||
Err(format_strbuf!("metadata not found: '{}'",
|
||||
filename.display()));
|
||||
Err(format!("metadata not found: '{}'", filename.display()));
|
||||
let cvbuf: *u8 = mem::transmute(cbuf);
|
||||
let vlen = encoder::metadata_encoding_version.len();
|
||||
debug!("checking {} bytes of metadata-version stamp",
|
||||
@ -566,8 +562,7 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, Str
|
||||
let version_ok = slice::raw::buf_as_slice(cvbuf, minsz,
|
||||
|buf0| buf0 == encoder::metadata_encoding_version);
|
||||
if !version_ok {
|
||||
return Err((format_strbuf!("incompatible metadata \
|
||||
version found: '{}'",
|
||||
return Err((format!("incompatible metadata version found: '{}'",
|
||||
filename.display())));
|
||||
}
|
||||
|
||||
@ -579,9 +574,9 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, Str
|
||||
Some(inflated) => found = Ok(MetadataVec(inflated)),
|
||||
None => {
|
||||
found =
|
||||
Err(format_strbuf!("failed to decompress \
|
||||
metadata for: '{}'",
|
||||
filename.display()))
|
||||
Err(format!("failed to decompress \
|
||||
metadata for: '{}'",
|
||||
filename.display()))
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -591,8 +586,7 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, Str
|
||||
}
|
||||
llvm::LLVMMoveToNextSection(si.llsi);
|
||||
}
|
||||
return Err(format_strbuf!("metadata not found: '{}'",
|
||||
filename.display()));
|
||||
return Err(format!("metadata not found: '{}'", filename.display()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ pub fn enc_ty(w: &mut MemWriter, cx: &ctxt, t: ty::t) {
|
||||
cx.abbrevs.borrow_mut().insert(t, ty_abbrev {
|
||||
pos: pos as uint,
|
||||
len: len as uint,
|
||||
s: format_strbuf!("\\#{:x}:{:x}\\#", pos, len)
|
||||
s: format!("\\#{:x}:{:x}\\#", pos, len)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ pub fn check_crate(tcx: &ty::ctxt,
|
||||
fn make_stat(bccx: &BorrowckCtxt, stat: uint) -> String {
|
||||
let stat_f = stat as f64;
|
||||
let total = bccx.stats.guaranteed_paths.get() as f64;
|
||||
format_strbuf!("{} ({:.0f}%)", stat , stat_f * 100.0 / total)
|
||||
format!("{} ({:.0f}%)", stat , stat_f * 100.0 / total)
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,7 +297,7 @@ impl BitAnd<RestrictionSet,RestrictionSet> for RestrictionSet {
|
||||
|
||||
impl Repr for RestrictionSet {
|
||||
fn repr(&self, _tcx: &ty::ctxt) -> String {
|
||||
format_strbuf!("RestrictionSet(0x{:x})", self.bits as uint)
|
||||
format!("RestrictionSet(0x{:x})", self.bits as uint)
|
||||
}
|
||||
}
|
||||
|
||||
@ -579,27 +579,27 @@ impl<'a> BorrowckCtxt<'a> {
|
||||
err_mutbl => {
|
||||
let descr = match opt_loan_path(&err.cmt) {
|
||||
None => {
|
||||
format_strbuf!("{} {}",
|
||||
err.cmt.mutbl.to_user_str(),
|
||||
self.cmt_to_str(&*err.cmt))
|
||||
format!("{} {}",
|
||||
err.cmt.mutbl.to_user_str(),
|
||||
self.cmt_to_str(&*err.cmt))
|
||||
}
|
||||
Some(lp) => {
|
||||
format_strbuf!("{} {} `{}`",
|
||||
err.cmt.mutbl.to_user_str(),
|
||||
self.cmt_to_str(&*err.cmt),
|
||||
self.loan_path_to_str(&*lp))
|
||||
format!("{} {} `{}`",
|
||||
err.cmt.mutbl.to_user_str(),
|
||||
self.cmt_to_str(&*err.cmt),
|
||||
self.loan_path_to_str(&*lp))
|
||||
}
|
||||
};
|
||||
|
||||
match err.cause {
|
||||
euv::ClosureCapture(_) => {
|
||||
format_strbuf!("closure cannot assign to {}", descr)
|
||||
format!("closure cannot assign to {}", descr)
|
||||
}
|
||||
euv::OverloadedOperator |
|
||||
euv::AddrOf |
|
||||
euv::RefBinding |
|
||||
euv::AutoRef => {
|
||||
format_strbuf!("cannot borrow {} as mutable", descr)
|
||||
format!("cannot borrow {} as mutable", descr)
|
||||
}
|
||||
euv::ClosureInvocation => {
|
||||
self.tcx.sess.span_bug(err.span,
|
||||
@ -611,20 +611,20 @@ impl<'a> BorrowckCtxt<'a> {
|
||||
let msg = match opt_loan_path(&err.cmt) {
|
||||
None => "borrowed value".to_string(),
|
||||
Some(lp) => {
|
||||
format_strbuf!("`{}`", self.loan_path_to_str(&*lp))
|
||||
format!("`{}`", self.loan_path_to_str(&*lp))
|
||||
}
|
||||
};
|
||||
format_strbuf!("{} does not live long enough", msg)
|
||||
format!("{} does not live long enough", msg)
|
||||
}
|
||||
err_borrowed_pointer_too_short(..) => {
|
||||
let descr = match opt_loan_path(&err.cmt) {
|
||||
Some(lp) => {
|
||||
format_strbuf!("`{}`", self.loan_path_to_str(&*lp))
|
||||
format!("`{}`", self.loan_path_to_str(&*lp))
|
||||
}
|
||||
None => self.cmt_to_str(&*err.cmt),
|
||||
};
|
||||
|
||||
format_strbuf!("lifetime of {} is too short to guarantee \
|
||||
format!("lifetime of {} is too short to guarantee \
|
||||
its contents can be safely reborrowed",
|
||||
descr)
|
||||
}
|
||||
@ -713,7 +713,7 @@ impl<'a> BorrowckCtxt<'a> {
|
||||
err_borrowed_pointer_too_short(loan_scope, ptr_scope, _) => {
|
||||
let descr = match opt_loan_path(&err.cmt) {
|
||||
Some(lp) => {
|
||||
format_strbuf!("`{}`", self.loan_path_to_str(&*lp))
|
||||
format!("`{}`", self.loan_path_to_str(&*lp))
|
||||
}
|
||||
None => self.cmt_to_str(&*err.cmt),
|
||||
};
|
||||
|
@ -190,7 +190,7 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: Vec<@Pat> ) {
|
||||
ty::ty_vec(..) | ty::ty_rptr(..) => {
|
||||
match *ctor {
|
||||
vec(n) => {
|
||||
Some(format_strbuf!("vectors of length {}", n))
|
||||
Some(format!("vectors of length {}", n))
|
||||
}
|
||||
_ => None
|
||||
}
|
||||
@ -199,8 +199,8 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: Vec<@Pat> ) {
|
||||
}
|
||||
}
|
||||
};
|
||||
let msg = format_strbuf!("non-exhaustive patterns{}", match ext {
|
||||
Some(ref s) => format_strbuf!(": {} not covered", *s),
|
||||
let msg = format!("non-exhaustive patterns{}", match ext {
|
||||
Some(ref s) => format!(": {} not covered", *s),
|
||||
None => "".to_string()
|
||||
});
|
||||
cx.tcx.sess.span_err(sp, msg.as_slice());
|
||||
|
@ -49,8 +49,7 @@ fn safe_type_for_static_mut(cx: &ty::ctxt, e: &ast::Expr) -> Option<String> {
|
||||
return None;
|
||||
};
|
||||
|
||||
Some(format_strbuf!("mutable static items are not allowed to have {}",
|
||||
suffix))
|
||||
Some(format!("mutable static items are not allowed to have {}", suffix))
|
||||
}
|
||||
|
||||
struct CheckStaticVisitor<'a> {
|
||||
|
@ -112,11 +112,8 @@ impl<'a, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, O> {
|
||||
"".to_string()
|
||||
};
|
||||
|
||||
try!(ps.synth_comment(format_strbuf!("id {}: {}{}{}",
|
||||
id,
|
||||
entry_str,
|
||||
gens_str,
|
||||
kills_str)));
|
||||
try!(ps.synth_comment(format!("id {}: {}{}{}", id, entry_str,
|
||||
gens_str, kills_str)));
|
||||
try!(pp::space(&mut ps.s));
|
||||
}
|
||||
Ok(())
|
||||
@ -895,5 +892,5 @@ fn set_bit(words: &mut [uint], bit: uint) -> bool {
|
||||
fn bit_str(bit: uint) -> String {
|
||||
let byte = bit >> 8;
|
||||
let lobits = 1 << (bit & 0xFF);
|
||||
format_strbuf!("[{}:{}-{:02x}]", bit, byte, lobits)
|
||||
format!("[{}:{}-{:02x}]", bit, byte, lobits)
|
||||
}
|
||||
|
@ -361,8 +361,8 @@ impl<'a> DeadVisitor<'a> {
|
||||
.add_lint(DeadCode,
|
||||
id,
|
||||
span,
|
||||
format_strbuf!("code is never used: `{}`",
|
||||
token::get_ident(ident)));
|
||||
format!("code is never used: `{}`",
|
||||
token::get_ident(ident)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,8 +78,8 @@ impl LanguageItems {
|
||||
match self.items.get(it as uint) {
|
||||
&Some(id) => Ok(id),
|
||||
&None => {
|
||||
Err(format_strbuf!("requires `{}` lang_item",
|
||||
LanguageItems::item_name(it as uint)))
|
||||
Err(format!("requires `{}` lang_item",
|
||||
LanguageItems::item_name(it as uint)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -154,13 +154,13 @@ fn live_node_kind_to_str(lnk: LiveNodeKind, cx: &ty::ctxt) -> String {
|
||||
let cm = cx.sess.codemap();
|
||||
match lnk {
|
||||
FreeVarNode(s) => {
|
||||
format_strbuf!("Free var node [{}]", cm.span_to_str(s))
|
||||
format!("Free var node [{}]", cm.span_to_str(s))
|
||||
}
|
||||
ExprNode(s) => {
|
||||
format_strbuf!("Expr node [{}]", cm.span_to_str(s))
|
||||
format!("Expr node [{}]", cm.span_to_str(s))
|
||||
}
|
||||
VarDefNode(s) => {
|
||||
format_strbuf!("Var def node [{}]", cm.span_to_str(s))
|
||||
format!("Var def node [{}]", cm.span_to_str(s))
|
||||
}
|
||||
ExitNode => "Exit node".to_string(),
|
||||
}
|
||||
@ -1594,12 +1594,11 @@ impl<'a> Liveness<'a> {
|
||||
|
||||
if is_assigned {
|
||||
self.ir.tcx.sess.add_lint(UnusedVariable, id, sp,
|
||||
format_strbuf!("variable `{}` is assigned to, \
|
||||
but never used",
|
||||
*name));
|
||||
format!("variable `{}` is assigned to, but never used",
|
||||
*name));
|
||||
} else {
|
||||
self.ir.tcx.sess.add_lint(UnusedVariable, id, sp,
|
||||
format_strbuf!("unused variable: `{}`", *name));
|
||||
format!("unused variable: `{}`", *name));
|
||||
}
|
||||
}
|
||||
true
|
||||
@ -1617,8 +1616,7 @@ impl<'a> Liveness<'a> {
|
||||
let r = self.should_warn(var);
|
||||
for name in r.iter() {
|
||||
self.ir.tcx.sess.add_lint(DeadAssignment, id, sp,
|
||||
format_strbuf!("value assigned to `{}` is never read",
|
||||
*name));
|
||||
format!("value assigned to `{}` is never read", *name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1116,8 +1116,7 @@ impl<'t,TYPER:Typer> MemCategorizationContext<'t,TYPER> {
|
||||
"captured outer variable".to_string()
|
||||
}
|
||||
_ => {
|
||||
format_strbuf!("dereference of `{}`-pointer",
|
||||
ptr_sigil(pk))
|
||||
format!("dereference of `{}`-pointer", ptr_sigil(pk))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1250,11 +1249,11 @@ impl cmt_ {
|
||||
|
||||
impl Repr for cmt_ {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
format_strbuf!("\\{{} id:{} m:{:?} ty:{}\\}",
|
||||
self.cat.repr(tcx),
|
||||
self.id,
|
||||
self.mutbl,
|
||||
self.ty.repr(tcx))
|
||||
format!("\\{{} id:{} m:{:?} ty:{}\\}",
|
||||
self.cat.repr(tcx),
|
||||
self.id,
|
||||
self.mutbl,
|
||||
self.ty.repr(tcx))
|
||||
}
|
||||
}
|
||||
|
||||
@ -1267,19 +1266,16 @@ impl Repr for categorization {
|
||||
cat_local(..) |
|
||||
cat_upvar(..) |
|
||||
cat_arg(..) => {
|
||||
format_strbuf!("{:?}", *self)
|
||||
format!("{:?}", *self)
|
||||
}
|
||||
cat_deref(ref cmt, derefs, ptr) => {
|
||||
format_strbuf!("{}-{}{}->",
|
||||
cmt.cat.repr(tcx),
|
||||
ptr_sigil(ptr),
|
||||
derefs)
|
||||
format!("{}-{}{}->", cmt.cat.repr(tcx), ptr_sigil(ptr), derefs)
|
||||
}
|
||||
cat_interior(ref cmt, interior) => {
|
||||
format_strbuf!("{}.{}", cmt.cat.repr(tcx), interior.repr(tcx))
|
||||
format!("{}.{}", cmt.cat.repr(tcx), interior.repr(tcx))
|
||||
}
|
||||
cat_downcast(ref cmt) => {
|
||||
format_strbuf!("{}->(enum)", cmt.cat.repr(tcx))
|
||||
format!("{}->(enum)", cmt.cat.repr(tcx))
|
||||
}
|
||||
cat_discr(ref cmt, _) => {
|
||||
cmt.cat.repr(tcx)
|
||||
@ -1305,7 +1301,7 @@ impl Repr for InteriorKind {
|
||||
InteriorField(NamedField(fld)) => {
|
||||
token::get_name(fld).get().to_str().to_string()
|
||||
}
|
||||
InteriorField(PositionalField(i)) => format_strbuf!("\\#{:?}", i),
|
||||
InteriorField(PositionalField(i)) => format!("\\#{:?}", i),
|
||||
InteriorElement(_) => "[]".to_string(),
|
||||
}
|
||||
}
|
||||
|
@ -547,9 +547,7 @@ impl<'a> PrivacyVisitor<'a> {
|
||||
source_did: Option<ast::DefId>, msg: &str) -> CheckResult {
|
||||
let id = match self.def_privacy(to_check) {
|
||||
ExternallyDenied => {
|
||||
return Some((span,
|
||||
format_strbuf!("{} is private", msg),
|
||||
None))
|
||||
return Some((span, format!("{} is private", msg), None))
|
||||
}
|
||||
Allowable => return None,
|
||||
DisallowedBy(id) => id,
|
||||
@ -560,11 +558,9 @@ impl<'a> PrivacyVisitor<'a> {
|
||||
// because the item itself is private or because its parent is private
|
||||
// and its parent isn't in our ancestry.
|
||||
let (err_span, err_msg) = if id == source_did.unwrap_or(to_check).node {
|
||||
return Some((span,
|
||||
format_strbuf!("{} is private", msg),
|
||||
None));
|
||||
return Some((span, format!("{} is private", msg), None));
|
||||
} else {
|
||||
(span, format_strbuf!("{} is inaccessible", msg))
|
||||
(span, format!("{} is inaccessible", msg))
|
||||
};
|
||||
let item = match self.tcx.map.find(id) {
|
||||
Some(ast_map::NodeItem(item)) => {
|
||||
@ -600,9 +596,8 @@ impl<'a> PrivacyVisitor<'a> {
|
||||
ast::ItemEnum(..) => "enum",
|
||||
_ => return Some((err_span, err_msg, None))
|
||||
};
|
||||
let msg = format_strbuf!("{} `{}` is private",
|
||||
desc,
|
||||
token::get_ident(item.ident));
|
||||
let msg = format!("{} `{}` is private", desc,
|
||||
token::get_ident(item.ident));
|
||||
Some((err_span, err_msg, Some((span, msg))))
|
||||
}
|
||||
|
||||
|
@ -405,7 +405,7 @@ impl<'a, 'b> Repr for Match<'a, 'b> {
|
||||
// for many programs, this just take too long to serialize
|
||||
self.pats.repr(tcx)
|
||||
} else {
|
||||
format_strbuf!("{} pats", self.pats.len())
|
||||
format!("{} pats", self.pats.len())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)
|
||||
|
||||
let mut clobbers = getClobbers();
|
||||
if !ia.clobbers.get().is_empty() && !clobbers.is_empty() {
|
||||
clobbers = format_strbuf!("{},{}", ia.clobbers.get(), clobbers);
|
||||
clobbers = format!("{},{}", ia.clobbers.get(), clobbers);
|
||||
} else {
|
||||
clobbers.push_str(ia.clobbers.get());
|
||||
}
|
||||
|
@ -698,10 +698,9 @@ pub fn iter_structural_ty<'r,
|
||||
for variant in (*variants).iter() {
|
||||
let variant_cx =
|
||||
fcx.new_temp_block(
|
||||
format_strbuf!("enum-iter-variant-{}",
|
||||
variant.disr_val
|
||||
.to_str()
|
||||
.as_slice()).as_slice());
|
||||
format!("enum-iter-variant-{}",
|
||||
variant.disr_val.to_str().as_slice())
|
||||
.as_slice());
|
||||
match adt::trans_case(cx, &*repr, variant.disr_val) {
|
||||
_match::single_result(r) => {
|
||||
AddCase(llswitch, r.val, variant_cx.llbb)
|
||||
|
@ -763,9 +763,9 @@ impl<'a> CleanupScope<'a> {
|
||||
*/
|
||||
|
||||
match self.kind {
|
||||
CustomScopeKind => format_strbuf!("{}_custom_", prefix),
|
||||
AstScopeKind(id) => format_strbuf!("{}_ast_{}_", prefix, id),
|
||||
LoopScopeKind(id, _) => format_strbuf!("{}_loop_{}_", prefix, id),
|
||||
CustomScopeKind => format!("{}_custom_", prefix),
|
||||
AstScopeKind(id) => format!("{}_ast_{}_", prefix, id),
|
||||
LoopScopeKind(id, _) => format!("{}_loop_{}_", prefix, id),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ pub struct EnvValue {
|
||||
|
||||
impl EnvValue {
|
||||
pub fn to_str(&self, ccx: &CrateContext) -> String {
|
||||
format_strbuf!("{}({})", self.action, self.datum.to_str(ccx))
|
||||
format!("{}({})", self.action, self.datum.to_str(ccx))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ impl param_substs {
|
||||
}
|
||||
|
||||
fn param_substs_to_str(this: ¶m_substs, tcx: &ty::ctxt) -> String {
|
||||
format_strbuf!("param_substs({})", this.substs.repr(tcx))
|
||||
format!("param_substs({})", this.substs.repr(tcx))
|
||||
}
|
||||
|
||||
impl Repr for param_substs {
|
||||
@ -478,7 +478,7 @@ impl<'a> Block<'a> {
|
||||
|
||||
pub fn to_str(&self) -> String {
|
||||
let blk: *Block = self;
|
||||
format_strbuf!("[block {}]", blk)
|
||||
format!("[block {}]", blk)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -625,10 +625,10 @@ impl<K:KindOps> Datum<K> {
|
||||
|
||||
#[allow(dead_code)] // useful for debugging
|
||||
pub fn to_str(&self, ccx: &CrateContext) -> String {
|
||||
format_strbuf!("Datum({}, {}, {:?})",
|
||||
ccx.tn.val_to_str(self.val),
|
||||
ty_to_str(ccx.tcx(), self.ty),
|
||||
self.kind)
|
||||
format!("Datum({}, {}, {:?})",
|
||||
ccx.tn.val_to_str(self.val),
|
||||
ty_to_str(ccx.tcx(), self.ty),
|
||||
self.kind)
|
||||
}
|
||||
|
||||
pub fn appropriate_rvalue_mode(&self, ccx: &CrateContext) -> RvalueMode {
|
||||
|
@ -2342,9 +2342,8 @@ fn cache_id_for_type(t: ty::t) -> uint {
|
||||
fn generate_unique_type_id(prefix: &'static str) -> String {
|
||||
unsafe {
|
||||
static mut unique_id_counter: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT;
|
||||
format_strbuf!("{}{}",
|
||||
prefix,
|
||||
unique_id_counter.fetch_add(1, atomics::SeqCst))
|
||||
format!("{}{}", prefix,
|
||||
unique_id_counter.fetch_add(1, atomics::SeqCst))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ pub enum Dest {
|
||||
impl Dest {
|
||||
pub fn to_str(&self, ccx: &CrateContext) -> String {
|
||||
match *self {
|
||||
SaveIn(v) => format_strbuf!("SaveIn({})", ccx.tn.val_to_str(v)),
|
||||
SaveIn(v) => format!("SaveIn({})", ccx.tn.val_to_str(v)),
|
||||
Ignore => "Ignore".to_string()
|
||||
}
|
||||
}
|
||||
|
@ -474,9 +474,7 @@ fn make_generic_glue(ccx: &CrateContext,
|
||||
name: &str)
|
||||
-> ValueRef {
|
||||
let _icx = push_ctxt("make_generic_glue");
|
||||
let glue_name = format_strbuf!("glue {} {}",
|
||||
name,
|
||||
ty_to_short_str(ccx.tcx(), t));
|
||||
let glue_name = format!("glue {} {}", name, ty_to_short_str(ccx.tcx(), t));
|
||||
let _s = StatRecorder::new(ccx, glue_name);
|
||||
|
||||
let arena = TypedArena::new();
|
||||
|
@ -19,7 +19,7 @@ pub trait LlvmRepr {
|
||||
impl<'a, T:LlvmRepr> LlvmRepr for &'a [T] {
|
||||
fn llrepr(&self, ccx: &CrateContext) -> String {
|
||||
let reprs: Vec<String> = self.iter().map(|t| t.llrepr(ccx)).collect();
|
||||
format_strbuf!("[{}]", reprs.connect(","))
|
||||
format!("[{}]", reprs.connect(","))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,10 +109,10 @@ pub fn monomorphic_fn(ccx: &CrateContext,
|
||||
ccx.sess(),
|
||||
ccx.tcx.map.find(fn_id.node),
|
||||
|| {
|
||||
format_strbuf!("while monomorphizing {:?}, couldn't find it in \
|
||||
the item map (may have attempted to monomorphize \
|
||||
an item defined in a different crate?)",
|
||||
fn_id)
|
||||
format!("while monomorphizing {:?}, couldn't find it in \
|
||||
the item map (may have attempted to monomorphize \
|
||||
an item defined in a different crate?)",
|
||||
fn_id)
|
||||
});
|
||||
|
||||
match map_node {
|
||||
|
@ -74,12 +74,12 @@ pub struct VecTypes {
|
||||
|
||||
impl VecTypes {
|
||||
pub fn to_str(&self, ccx: &CrateContext) -> String {
|
||||
format_strbuf!("VecTypes \\{unit_ty={}, llunit_ty={}, \
|
||||
llunit_size={}, llunit_alloc_size={}\\}",
|
||||
ty_to_str(ccx.tcx(), self.unit_ty),
|
||||
ccx.tn.type_to_str(self.llunit_ty),
|
||||
ccx.tn.val_to_str(self.llunit_size),
|
||||
self.llunit_alloc_size)
|
||||
format!("VecTypes \\{unit_ty={}, llunit_ty={}, \
|
||||
llunit_size={}, llunit_alloc_size={}\\}",
|
||||
ty_to_str(ccx.tcx(), self.unit_ty),
|
||||
ccx.tn.type_to_str(self.llunit_ty),
|
||||
ccx.tn.val_to_str(self.llunit_size),
|
||||
self.llunit_alloc_size)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -316,9 +316,9 @@ pub fn llvm_type_name(cx: &CrateContext,
|
||||
did,
|
||||
false);
|
||||
if did.krate == 0 {
|
||||
format_strbuf!("{}.{}", name, tstr)
|
||||
format!("{}.{}", name, tstr)
|
||||
} else {
|
||||
format_strbuf!("{}.{}[\\#{}]", name, tstr, did.krate)
|
||||
format!("{}.{}[\\#{}]", name, tstr, did.krate)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3236,7 +3236,7 @@ pub fn ty_sort_str(cx: &ctxt, t: t) -> String {
|
||||
::util::ppaux::ty_to_str(cx, t)
|
||||
}
|
||||
|
||||
ty_enum(id, _) => format_strbuf!("enum {}", item_path_str(cx, id)),
|
||||
ty_enum(id, _) => format!("enum {}", item_path_str(cx, id)),
|
||||
ty_box(_) => "@-ptr".to_string(),
|
||||
ty_uniq(_) => "box".to_string(),
|
||||
ty_vec(_, _) => "vector".to_string(),
|
||||
@ -3245,10 +3245,10 @@ pub fn ty_sort_str(cx: &ctxt, t: t) -> String {
|
||||
ty_bare_fn(_) => "extern fn".to_string(),
|
||||
ty_closure(_) => "fn".to_string(),
|
||||
ty_trait(ref inner) => {
|
||||
format_strbuf!("trait {}", item_path_str(cx, inner.def_id))
|
||||
format!("trait {}", item_path_str(cx, inner.def_id))
|
||||
}
|
||||
ty_struct(id, _) => {
|
||||
format_strbuf!("struct {}", item_path_str(cx, id))
|
||||
format!("struct {}", item_path_str(cx, id))
|
||||
}
|
||||
ty_tup(_) => "tuple".to_string(),
|
||||
ty_infer(TyVar(_)) => "inferred type".to_string(),
|
||||
@ -3280,24 +3280,24 @@ pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> String {
|
||||
match *err {
|
||||
terr_mismatch => "types differ".to_string(),
|
||||
terr_fn_style_mismatch(values) => {
|
||||
format_strbuf!("expected {} fn but found {} fn",
|
||||
values.expected.to_str(),
|
||||
values.found.to_str())
|
||||
format!("expected {} fn but found {} fn",
|
||||
values.expected.to_str(),
|
||||
values.found.to_str())
|
||||
}
|
||||
terr_abi_mismatch(values) => {
|
||||
format_strbuf!("expected {} fn but found {} fn",
|
||||
values.expected.to_str(),
|
||||
values.found.to_str())
|
||||
format!("expected {} fn but found {} fn",
|
||||
values.expected.to_str(),
|
||||
values.found.to_str())
|
||||
}
|
||||
terr_onceness_mismatch(values) => {
|
||||
format_strbuf!("expected {} fn but found {} fn",
|
||||
values.expected.to_str(),
|
||||
values.found.to_str())
|
||||
format!("expected {} fn but found {} fn",
|
||||
values.expected.to_str(),
|
||||
values.found.to_str())
|
||||
}
|
||||
terr_sigil_mismatch(values) => {
|
||||
format_strbuf!("expected {}, found {}",
|
||||
tstore_to_closure(&values.expected),
|
||||
tstore_to_closure(&values.found))
|
||||
format!("expected {}, found {}",
|
||||
tstore_to_closure(&values.expected),
|
||||
tstore_to_closure(&values.found))
|
||||
}
|
||||
terr_mutability => "values differ in mutability".to_string(),
|
||||
terr_box_mutability => {
|
||||
@ -3307,31 +3307,31 @@ pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> String {
|
||||
terr_ptr_mutability => "pointers differ in mutability".to_string(),
|
||||
terr_ref_mutability => "references differ in mutability".to_string(),
|
||||
terr_ty_param_size(values) => {
|
||||
format_strbuf!("expected a type with {} type params \
|
||||
but found one with {} type params",
|
||||
values.expected,
|
||||
values.found)
|
||||
format!("expected a type with {} type params \
|
||||
but found one with {} type params",
|
||||
values.expected,
|
||||
values.found)
|
||||
}
|
||||
terr_tuple_size(values) => {
|
||||
format_strbuf!("expected a tuple with {} elements \
|
||||
but found one with {} elements",
|
||||
values.expected,
|
||||
values.found)
|
||||
format!("expected a tuple with {} elements \
|
||||
but found one with {} elements",
|
||||
values.expected,
|
||||
values.found)
|
||||
}
|
||||
terr_record_size(values) => {
|
||||
format_strbuf!("expected a record with {} fields \
|
||||
but found one with {} fields",
|
||||
values.expected,
|
||||
values.found)
|
||||
format!("expected a record with {} fields \
|
||||
but found one with {} fields",
|
||||
values.expected,
|
||||
values.found)
|
||||
}
|
||||
terr_record_mutability => {
|
||||
"record elements differ in mutability".to_string()
|
||||
}
|
||||
terr_record_fields(values) => {
|
||||
format_strbuf!("expected a record with field `{}` but found one \
|
||||
with field `{}`",
|
||||
token::get_ident(values.expected),
|
||||
token::get_ident(values.found))
|
||||
format!("expected a record with field `{}` but found one \
|
||||
with field `{}`",
|
||||
token::get_ident(values.expected),
|
||||
token::get_ident(values.found))
|
||||
}
|
||||
terr_arg_count => {
|
||||
"incorrect number of function parameters".to_string()
|
||||
@ -3346,69 +3346,60 @@ pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> String {
|
||||
"lifetimes do not intersect".to_string()
|
||||
}
|
||||
terr_regions_insufficiently_polymorphic(br, _) => {
|
||||
format_strbuf!("expected bound lifetime parameter {}, \
|
||||
but found concrete lifetime",
|
||||
bound_region_ptr_to_str(cx, br))
|
||||
format!("expected bound lifetime parameter {}, \
|
||||
but found concrete lifetime",
|
||||
bound_region_ptr_to_str(cx, br))
|
||||
}
|
||||
terr_regions_overly_polymorphic(br, _) => {
|
||||
format_strbuf!("expected concrete lifetime, \
|
||||
but found bound lifetime parameter {}",
|
||||
bound_region_ptr_to_str(cx, br))
|
||||
format!("expected concrete lifetime, \
|
||||
but found bound lifetime parameter {}",
|
||||
bound_region_ptr_to_str(cx, br))
|
||||
}
|
||||
terr_trait_stores_differ(_, ref values) => {
|
||||
format_strbuf!("trait storage differs: expected `{}` but found \
|
||||
`{}`",
|
||||
trait_store_to_str(cx, (*values).expected),
|
||||
trait_store_to_str(cx, (*values).found))
|
||||
format!("trait storage differs: expected `{}` but found `{}`",
|
||||
trait_store_to_str(cx, (*values).expected),
|
||||
trait_store_to_str(cx, (*values).found))
|
||||
}
|
||||
terr_sorts(values) => {
|
||||
format_strbuf!("expected {} but found {}",
|
||||
ty_sort_str(cx, values.expected),
|
||||
ty_sort_str(cx, values.found))
|
||||
format!("expected {} but found {}",
|
||||
ty_sort_str(cx, values.expected),
|
||||
ty_sort_str(cx, values.found))
|
||||
}
|
||||
terr_traits(values) => {
|
||||
format_strbuf!("expected trait `{}` but found trait `{}`",
|
||||
item_path_str(cx, values.expected),
|
||||
item_path_str(cx, values.found))
|
||||
format!("expected trait `{}` but found trait `{}`",
|
||||
item_path_str(cx, values.expected),
|
||||
item_path_str(cx, values.found))
|
||||
}
|
||||
terr_builtin_bounds(values) => {
|
||||
if values.expected.is_empty() {
|
||||
format_strbuf!("expected no bounds but found `{}`",
|
||||
values.found.user_string(cx))
|
||||
format!("expected no bounds but found `{}`",
|
||||
values.found.user_string(cx))
|
||||
} else if values.found.is_empty() {
|
||||
format_strbuf!("expected bounds `{}` but found no bounds",
|
||||
values.expected.user_string(cx))
|
||||
format!("expected bounds `{}` but found no bounds",
|
||||
values.expected.user_string(cx))
|
||||
} else {
|
||||
format_strbuf!("expected bounds `{}` but found bounds `{}`",
|
||||
values.expected.user_string(cx),
|
||||
values.found.user_string(cx))
|
||||
format!("expected bounds `{}` but found bounds `{}`",
|
||||
values.expected.user_string(cx),
|
||||
values.found.user_string(cx))
|
||||
}
|
||||
}
|
||||
terr_integer_as_char => {
|
||||
"expected an integral type but found `char`".to_string()
|
||||
}
|
||||
terr_int_mismatch(ref values) => {
|
||||
format_strbuf!("expected `{}` but found `{}`",
|
||||
values.expected.to_str(),
|
||||
values.found.to_str())
|
||||
format!("expected `{}` but found `{}`",
|
||||
values.expected.to_str(),
|
||||
values.found.to_str())
|
||||
}
|
||||
terr_float_mismatch(ref values) => {
|
||||
format_strbuf!("expected `{}` but found `{}`",
|
||||
values.expected.to_str(),
|
||||
values.found.to_str())
|
||||
format!("expected `{}` but found `{}`",
|
||||
values.expected.to_str(),
|
||||
values.found.to_str())
|
||||
}
|
||||
terr_variadic_mismatch(ref values) => {
|
||||
format_strbuf!("expected {} fn but found {} function",
|
||||
if values.expected {
|
||||
"variadic"
|
||||
} else {
|
||||
"non-variadic"
|
||||
},
|
||||
if values.found {
|
||||
"variadic"
|
||||
} else {
|
||||
"non-variadic"
|
||||
})
|
||||
format!("expected {} fn but found {} function",
|
||||
if values.expected { "variadic" } else { "non-variadic" },
|
||||
if values.found { "variadic" } else { "non-variadic" })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -167,10 +167,8 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: &ast::Pat, path: &ast::Path,
|
||||
fcx.infcx().type_error_message_str_with_expected(pat.span,
|
||||
|expected, actual| {
|
||||
expected.map_or("".to_string(), |e| {
|
||||
format_strbuf!("mismatched types: expected `{}` but \
|
||||
found {}",
|
||||
e,
|
||||
actual)
|
||||
format!("mismatched types: expected `{}` but found {}",
|
||||
e, actual)
|
||||
})},
|
||||
Some(expected),
|
||||
"a structure pattern".to_string(),
|
||||
@ -223,10 +221,8 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: &ast::Pat, path: &ast::Path,
|
||||
|expected, actual| {
|
||||
expected.map_or("".to_string(),
|
||||
|e| {
|
||||
format_strbuf!("mismatched types: expected `{}` but \
|
||||
found {}",
|
||||
e,
|
||||
actual)
|
||||
format!("mismatched types: expected `{}` but found {}",
|
||||
e, actual)
|
||||
})
|
||||
},
|
||||
Some(expected),
|
||||
@ -555,10 +551,8 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
|
||||
|expected, actual| {
|
||||
expected.map_or("".to_string(),
|
||||
|e| {
|
||||
format_strbuf!("mismatched types: expected \
|
||||
`{}` but found {}",
|
||||
e,
|
||||
actual)
|
||||
format!("mismatched types: expected \
|
||||
`{}` but found {}", e, actual)
|
||||
})},
|
||||
Some(expected),
|
||||
"a structure pattern".to_string(),
|
||||
@ -621,10 +615,8 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
|
||||
|expected,
|
||||
actual| {
|
||||
expected.map_or("".to_string(), |e| {
|
||||
format_strbuf!("mismatched types: expected `{}` \
|
||||
but found {}",
|
||||
e,
|
||||
actual)
|
||||
format!("mismatched types: expected `{}` \
|
||||
but found {}", e, actual)
|
||||
}
|
||||
)},
|
||||
Some(expected),
|
||||
@ -661,10 +653,8 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
|
||||
|expected, actual| {
|
||||
expected.map_or("".to_string(),
|
||||
|e| {
|
||||
format_strbuf!("mismatched types: expected `{}` but \
|
||||
found {}",
|
||||
e,
|
||||
actual)
|
||||
format!("mismatched types: expected `{}` but found {}",
|
||||
e, actual)
|
||||
})
|
||||
},
|
||||
Some(expected),
|
||||
@ -751,14 +741,12 @@ pub fn check_pointer_pat(pcx: &pat_ctxt,
|
||||
span,
|
||||
|expected, actual| {
|
||||
expected.map_or("".to_string(), |e| {
|
||||
format_strbuf!("mismatched types: expected `{}` but \
|
||||
found {}",
|
||||
e,
|
||||
actual)
|
||||
format!("mismatched types: expected `{}` but found {}",
|
||||
e, actual)
|
||||
})
|
||||
},
|
||||
Some(expected),
|
||||
format_strbuf!("{} pattern", match pointer_kind {
|
||||
format!("{} pattern", match pointer_kind {
|
||||
Send => "a box",
|
||||
Borrowed => "an `&`-pointer",
|
||||
}),
|
||||
|
@ -1510,12 +1510,12 @@ impl<'a> LookupContext<'a> {
|
||||
|
||||
impl Repr for Candidate {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
format_strbuf!("Candidate(rcvr_ty={}, rcvr_substs={}, method_ty={}, \
|
||||
origin={:?})",
|
||||
self.rcvr_match_condition.repr(tcx),
|
||||
self.rcvr_substs.repr(tcx),
|
||||
self.method_ty.repr(tcx),
|
||||
self.origin)
|
||||
format!("Candidate(rcvr_ty={}, rcvr_substs={}, method_ty={}, \
|
||||
origin={:?})",
|
||||
self.rcvr_match_condition.repr(tcx),
|
||||
self.rcvr_substs.repr(tcx),
|
||||
self.method_ty.repr(tcx),
|
||||
self.origin)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1523,10 +1523,10 @@ impl Repr for RcvrMatchCondition {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
match *self {
|
||||
RcvrMatchesIfObject(d) => {
|
||||
format_strbuf!("RcvrMatchesIfObject({})", d.repr(tcx))
|
||||
format!("RcvrMatchesIfObject({})", d.repr(tcx))
|
||||
}
|
||||
RcvrMatchesIfSubtype(t) => {
|
||||
format_strbuf!("RcvrMatchesIfSubtype({})", t.repr(tcx))
|
||||
format!("RcvrMatchesIfSubtype({})", t.repr(tcx))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1101,7 +1101,7 @@ impl<'a> RegionScope for infer::InferCtxt<'a> {
|
||||
|
||||
impl<'a> FnCtxt<'a> {
|
||||
pub fn tag(&self) -> String {
|
||||
format_strbuf!("{}", self as *FnCtxt)
|
||||
format!("{}", self as *FnCtxt)
|
||||
}
|
||||
|
||||
pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> ty::t {
|
||||
@ -1877,21 +1877,21 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
||||
ty::ty_float(ast::TyF32) => {
|
||||
fcx.type_error_message(arg.span,
|
||||
|t| {
|
||||
format_strbuf!("can't pass an {} to variadic \
|
||||
function, cast to c_double", t)
|
||||
format!("can't pass an {} to variadic \
|
||||
function, cast to c_double", t)
|
||||
}, arg_ty, None);
|
||||
}
|
||||
ty::ty_int(ast::TyI8) | ty::ty_int(ast::TyI16) | ty::ty_bool => {
|
||||
fcx.type_error_message(arg.span, |t| {
|
||||
format_strbuf!("can't pass {} to variadic \
|
||||
function, cast to c_int",
|
||||
format!("can't pass {} to variadic \
|
||||
function, cast to c_int",
|
||||
t)
|
||||
}, arg_ty, None);
|
||||
}
|
||||
ty::ty_uint(ast::TyU8) | ty::ty_uint(ast::TyU16) => {
|
||||
fcx.type_error_message(arg.span, |t| {
|
||||
format_strbuf!("can't pass {} to variadic \
|
||||
function, cast to c_uint",
|
||||
format!("can't pass {} to variadic \
|
||||
function, cast to c_uint",
|
||||
t)
|
||||
}, arg_ty, None);
|
||||
}
|
||||
@ -1939,7 +1939,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
||||
ty::ty_closure(box ty::ClosureTy {sig: ref sig, ..}) => sig,
|
||||
_ => {
|
||||
fcx.type_error_message(call_expr.span, |actual| {
|
||||
format_strbuf!("expected function but found `{}`", actual)
|
||||
format!("expected function but found `{}`", actual)
|
||||
}, fn_ty, None);
|
||||
&error_fn_sig
|
||||
}
|
||||
@ -1993,10 +1993,10 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
||||
|
||||
fcx.type_error_message(method_name.span,
|
||||
|actual| {
|
||||
format_strbuf!("type `{}` does not implement any \
|
||||
method in scope named `{}`",
|
||||
actual,
|
||||
token::get_ident(method_name.node))
|
||||
format!("type `{}` does not implement any \
|
||||
method in scope named `{}`",
|
||||
actual,
|
||||
token::get_ident(method_name.node))
|
||||
},
|
||||
expr_t,
|
||||
None);
|
||||
@ -2148,12 +2148,12 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
||||
if ty::type_is_fp(ty::simd_type(tcx, lhs_t)) {
|
||||
fcx.type_error_message(expr.span,
|
||||
|actual| {
|
||||
format_strbuf!("binary comparison \
|
||||
operation `{}` not \
|
||||
supported for floating \
|
||||
point SIMD vector `{}`",
|
||||
ast_util::binop_to_str(op),
|
||||
actual)
|
||||
format!("binary comparison \
|
||||
operation `{}` not \
|
||||
supported for floating \
|
||||
point SIMD vector `{}`",
|
||||
ast_util::binop_to_str(op),
|
||||
actual)
|
||||
},
|
||||
lhs_t,
|
||||
None
|
||||
@ -2180,10 +2180,10 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
||||
fcx.write_error(rhs.id);
|
||||
fcx.type_error_message(expr.span,
|
||||
|actual| {
|
||||
format_strbuf!("binary operation `{}` cannot be applied \
|
||||
to type `{}`",
|
||||
ast_util::binop_to_str(op),
|
||||
actual)
|
||||
format!("binary operation `{}` cannot be applied \
|
||||
to type `{}`",
|
||||
ast_util::binop_to_str(op),
|
||||
actual)
|
||||
},
|
||||
lhs_t,
|
||||
None)
|
||||
@ -2195,12 +2195,12 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
||||
} else {
|
||||
fcx.type_error_message(expr.span,
|
||||
|actual| {
|
||||
format_strbuf!("binary assignment \
|
||||
operation `{}=` \
|
||||
cannot be applied to \
|
||||
type `{}`",
|
||||
ast_util::binop_to_str(op),
|
||||
actual)
|
||||
format!("binary assignment \
|
||||
operation `{}=` \
|
||||
cannot be applied to \
|
||||
type `{}`",
|
||||
ast_util::binop_to_str(op),
|
||||
actual)
|
||||
},
|
||||
lhs_t,
|
||||
None);
|
||||
@ -2247,10 +2247,9 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
||||
lookup_op_method(fcx, ex, lhs_resolved_t, token::intern(name),
|
||||
trait_did, [lhs_expr, rhs], DontAutoderefReceiver, || {
|
||||
fcx.type_error_message(ex.span, |actual| {
|
||||
format_strbuf!("binary operation `{}` cannot be applied to \
|
||||
type `{}`",
|
||||
ast_util::binop_to_str(op),
|
||||
actual)
|
||||
format!("binary operation `{}` cannot be applied to type `{}`",
|
||||
ast_util::binop_to_str(op),
|
||||
actual)
|
||||
}, lhs_resolved_t, None)
|
||||
})
|
||||
}
|
||||
@ -2265,10 +2264,8 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
||||
lookup_op_method(fcx, ex, rhs_t, token::intern(mname),
|
||||
trait_did, [rhs_expr], DontAutoderefReceiver, || {
|
||||
fcx.type_error_message(ex.span, |actual| {
|
||||
format_strbuf!("cannot apply unary operator `{}` to type \
|
||||
`{}`",
|
||||
op_str,
|
||||
actual)
|
||||
format!("cannot apply unary operator `{}` to type `{}`",
|
||||
op_str, actual)
|
||||
}, rhs_t, None);
|
||||
})
|
||||
}
|
||||
@ -2427,10 +2424,8 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
||||
fcx.type_error_message(
|
||||
expr.span,
|
||||
|actual| {
|
||||
format_strbuf!("attempted to take value of method \
|
||||
`{}` on type `{}`",
|
||||
token::get_name(field),
|
||||
actual)
|
||||
format!("attempted to take value of method `{}` on type \
|
||||
`{}`", token::get_name(field), actual)
|
||||
},
|
||||
expr_t, None);
|
||||
|
||||
@ -2442,7 +2437,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
||||
fcx.type_error_message(
|
||||
expr.span,
|
||||
|actual| {
|
||||
format_strbuf!("attempted access of field `{}` on \
|
||||
format!("attempted access of field `{}` on \
|
||||
type `{}`, but no field with that \
|
||||
name was found",
|
||||
token::get_name(field),
|
||||
@ -2484,10 +2479,8 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
||||
fcx.type_error_message(
|
||||
field.ident.span,
|
||||
|actual| {
|
||||
format_strbuf!("structure `{}` has no field named \
|
||||
`{}`",
|
||||
actual,
|
||||
token::get_ident(field.ident.node))
|
||||
format!("structure `{}` has no field named `{}`",
|
||||
actual, token::get_ident(field.ident.node))
|
||||
},
|
||||
struct_ty,
|
||||
None);
|
||||
@ -2876,9 +2869,8 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
||||
no longer be dereferenced");
|
||||
} else {
|
||||
fcx.type_error_message(expr.span, |actual| {
|
||||
format_strbuf!("type `{}` cannot be \
|
||||
dereferenced",
|
||||
actual)
|
||||
format!("type `{}` cannot be \
|
||||
dereferenced", actual)
|
||||
}, oprnd_t, None);
|
||||
}
|
||||
ty::mk_err()
|
||||
@ -3119,15 +3111,15 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
||||
_ => {
|
||||
if ty::type_is_nil(t_e) {
|
||||
fcx.type_error_message(expr.span, |actual| {
|
||||
format_strbuf!("cast from nil: `{}` as `{}`",
|
||||
actual,
|
||||
fcx.infcx().ty_to_str(t_1))
|
||||
format!("cast from nil: `{}` as `{}`",
|
||||
actual,
|
||||
fcx.infcx().ty_to_str(t_1))
|
||||
}, t_e, None);
|
||||
} else if ty::type_is_nil(t_1) {
|
||||
fcx.type_error_message(expr.span, |actual| {
|
||||
format_strbuf!("cast to nil: `{}` as `{}`",
|
||||
actual,
|
||||
fcx.infcx().ty_to_str(t_1))
|
||||
format!("cast to nil: `{}` as `{}`",
|
||||
actual,
|
||||
fcx.infcx().ty_to_str(t_1))
|
||||
}, t_e, None);
|
||||
}
|
||||
|
||||
@ -3147,9 +3139,8 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
||||
let te = fcx.infcx().resolve_type_vars_if_possible(te);
|
||||
if ty::get(te).sty != ty::ty_uint(ast::TyU8) {
|
||||
fcx.type_error_message(expr.span, |actual| {
|
||||
format_strbuf!("only `u8` can be cast as \
|
||||
`char`, not `{}`",
|
||||
actual)
|
||||
format!("only `u8` can be cast as \
|
||||
`char`, not `{}`", actual)
|
||||
}, t_e, None);
|
||||
}
|
||||
} else if ty::get(t1).sty == ty::ty_bool {
|
||||
@ -3211,9 +3202,9 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
||||
record the issue number in this comment.
|
||||
*/
|
||||
fcx.type_error_message(expr.span, |actual| {
|
||||
format_strbuf!("non-scalar cast: `{}` as `{}`",
|
||||
actual,
|
||||
fcx.infcx().ty_to_str(t_1))
|
||||
format!("non-scalar cast: `{}` as `{}`",
|
||||
actual,
|
||||
fcx.infcx().ty_to_str(t_1))
|
||||
}, t_e, None);
|
||||
}
|
||||
}
|
||||
@ -3332,12 +3323,9 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
||||
|| {
|
||||
fcx.type_error_message(expr.span,
|
||||
|actual| {
|
||||
format_strbuf!("cannot \
|
||||
index a \
|
||||
value of \
|
||||
type \
|
||||
`{}`",
|
||||
actual)
|
||||
format!("cannot index a \
|
||||
value of type \
|
||||
`{}`", actual)
|
||||
},
|
||||
base_t,
|
||||
None);
|
||||
@ -3364,9 +3352,8 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
||||
pub fn require_uint(fcx: &FnCtxt, sp: Span, t: ty::t) {
|
||||
if !type_is_uint(fcx, sp, t) {
|
||||
fcx.type_error_message(sp, |actual| {
|
||||
format_strbuf!("mismatched types: expected `uint` type but found \
|
||||
`{}`",
|
||||
actual)
|
||||
format!("mismatched types: expected `uint` type but found `{}`",
|
||||
actual)
|
||||
}, t, None);
|
||||
}
|
||||
}
|
||||
@ -3374,9 +3361,8 @@ pub fn require_uint(fcx: &FnCtxt, sp: Span, t: ty::t) {
|
||||
pub fn require_integral(fcx: &FnCtxt, sp: Span, t: ty::t) {
|
||||
if !type_is_integral(fcx, sp, t) {
|
||||
fcx.type_error_message(sp, |actual| {
|
||||
format_strbuf!("mismatched types: expected integral type but \
|
||||
found `{}`",
|
||||
actual)
|
||||
format!("mismatched types: expected integral type but found `{}`",
|
||||
actual)
|
||||
}, t, None);
|
||||
}
|
||||
}
|
||||
@ -4513,8 +4499,8 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
||||
i_ty.ty,
|
||||
fty,
|
||||
|| {
|
||||
format_strbuf!("intrinsic has wrong type: expected `{}`",
|
||||
ppaux::ty_to_str(ccx.tcx, fty))
|
||||
format!("intrinsic has wrong type: expected `{}`",
|
||||
ppaux::ty_to_str(ccx.tcx, fty))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -395,9 +395,9 @@ impl<'a> ErrorReporting for InferCtxt<'a> {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(format_strbuf!("expected `{}` but found `{}`",
|
||||
expected.user_string(self.tcx),
|
||||
found.user_string(self.tcx)))
|
||||
Some(format!("expected `{}` but found `{}`",
|
||||
expected.user_string(self.tcx),
|
||||
found.user_string(self.tcx)))
|
||||
}
|
||||
|
||||
fn report_concrete_failure(&self,
|
||||
|
@ -252,10 +252,8 @@ pub fn fixup_err_to_str(f: fixup_err) -> String {
|
||||
cyclic_ty(_) => "cyclic type of infinite size".to_string(),
|
||||
unresolved_region(_) => "unconstrained region".to_string(),
|
||||
region_var_bound_by_region_var(r1, r2) => {
|
||||
format_strbuf!("region var {:?} bound by another region var {:?}; \
|
||||
this is a bug in rustc",
|
||||
r1,
|
||||
r2)
|
||||
format!("region var {:?} bound by another region var {:?}; \
|
||||
this is a bug in rustc", r1, r2)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -657,7 +655,7 @@ impl<'a> InferCtxt<'a> {
|
||||
|
||||
pub fn tys_to_str(&self, ts: &[ty::t]) -> String {
|
||||
let tstrs: Vec<String> = ts.iter().map(|t| self.ty_to_str(*t)).collect();
|
||||
format_strbuf!("({})", tstrs.connect(", "))
|
||||
format!("({})", tstrs.connect(", "))
|
||||
}
|
||||
|
||||
pub fn trait_ref_to_str(&self, t: &ty::TraitRef) -> String {
|
||||
@ -786,10 +784,9 @@ impl<'a> InferCtxt<'a> {
|
||||
_ => {
|
||||
// if I leave out : String, it infers &str and complains
|
||||
|actual: String| {
|
||||
format_strbuf!("mismatched types: expected `{}` but \
|
||||
found `{}`",
|
||||
self.ty_to_str(resolved_expected),
|
||||
actual)
|
||||
format!("mismatched types: expected `{}` but found `{}`",
|
||||
self.ty_to_str(resolved_expected),
|
||||
actual)
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -830,7 +827,7 @@ impl TypeTrace {
|
||||
|
||||
impl Repr for TypeTrace {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
format_strbuf!("TypeTrace({})", self.origin.repr(tcx))
|
||||
format!("TypeTrace({})", self.origin.repr(tcx))
|
||||
}
|
||||
}
|
||||
|
||||
@ -852,23 +849,23 @@ impl Repr for TypeOrigin {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
match *self {
|
||||
MethodCompatCheck(a) => {
|
||||
format_strbuf!("MethodCompatCheck({})", a.repr(tcx))
|
||||
format!("MethodCompatCheck({})", a.repr(tcx))
|
||||
}
|
||||
ExprAssignable(a) => {
|
||||
format_strbuf!("ExprAssignable({})", a.repr(tcx))
|
||||
format!("ExprAssignable({})", a.repr(tcx))
|
||||
}
|
||||
Misc(a) => format_strbuf!("Misc({})", a.repr(tcx)),
|
||||
Misc(a) => format!("Misc({})", a.repr(tcx)),
|
||||
RelateTraitRefs(a) => {
|
||||
format_strbuf!("RelateTraitRefs({})", a.repr(tcx))
|
||||
format!("RelateTraitRefs({})", a.repr(tcx))
|
||||
}
|
||||
RelateSelfType(a) => {
|
||||
format_strbuf!("RelateSelfType({})", a.repr(tcx))
|
||||
format!("RelateSelfType({})", a.repr(tcx))
|
||||
}
|
||||
MatchExpression(a) => {
|
||||
format_strbuf!("MatchExpression({})", a.repr(tcx))
|
||||
format!("MatchExpression({})", a.repr(tcx))
|
||||
}
|
||||
IfExpression(a) => {
|
||||
format_strbuf!("IfExpression({})", a.repr(tcx))
|
||||
format!("IfExpression({})", a.repr(tcx))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -901,41 +898,41 @@ impl Repr for SubregionOrigin {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
match *self {
|
||||
Subtype(ref a) => {
|
||||
format_strbuf!("Subtype({})", a.repr(tcx))
|
||||
format!("Subtype({})", a.repr(tcx))
|
||||
}
|
||||
InfStackClosure(a) => {
|
||||
format_strbuf!("InfStackClosure({})", a.repr(tcx))
|
||||
format!("InfStackClosure({})", a.repr(tcx))
|
||||
}
|
||||
InvokeClosure(a) => {
|
||||
format_strbuf!("InvokeClosure({})", a.repr(tcx))
|
||||
format!("InvokeClosure({})", a.repr(tcx))
|
||||
}
|
||||
DerefPointer(a) => {
|
||||
format_strbuf!("DerefPointer({})", a.repr(tcx))
|
||||
format!("DerefPointer({})", a.repr(tcx))
|
||||
}
|
||||
FreeVariable(a, b) => {
|
||||
format_strbuf!("FreeVariable({}, {})", a.repr(tcx), b)
|
||||
format!("FreeVariable({}, {})", a.repr(tcx), b)
|
||||
}
|
||||
IndexSlice(a) => {
|
||||
format_strbuf!("IndexSlice({})", a.repr(tcx))
|
||||
format!("IndexSlice({})", a.repr(tcx))
|
||||
}
|
||||
RelateObjectBound(a) => {
|
||||
format_strbuf!("RelateObjectBound({})", a.repr(tcx))
|
||||
format!("RelateObjectBound({})", a.repr(tcx))
|
||||
}
|
||||
Reborrow(a) => format_strbuf!("Reborrow({})", a.repr(tcx)),
|
||||
Reborrow(a) => format!("Reborrow({})", a.repr(tcx)),
|
||||
ReborrowUpvar(a, b) => {
|
||||
format_strbuf!("ReborrowUpvar({},{:?})", a.repr(tcx), b)
|
||||
format!("ReborrowUpvar({},{:?})", a.repr(tcx), b)
|
||||
}
|
||||
ReferenceOutlivesReferent(_, a) => {
|
||||
format_strbuf!("ReferenceOutlivesReferent({})", a.repr(tcx))
|
||||
format!("ReferenceOutlivesReferent({})", a.repr(tcx))
|
||||
}
|
||||
BindingTypeIsNotValidAtDecl(a) => {
|
||||
format_strbuf!("BindingTypeIsNotValidAtDecl({})", a.repr(tcx))
|
||||
format!("BindingTypeIsNotValidAtDecl({})", a.repr(tcx))
|
||||
}
|
||||
CallRcvr(a) => format_strbuf!("CallRcvr({})", a.repr(tcx)),
|
||||
CallArg(a) => format_strbuf!("CallArg({})", a.repr(tcx)),
|
||||
CallReturn(a) => format_strbuf!("CallReturn({})", a.repr(tcx)),
|
||||
AddrOf(a) => format_strbuf!("AddrOf({})", a.repr(tcx)),
|
||||
AutoBorrow(a) => format_strbuf!("AutoBorrow({})", a.repr(tcx)),
|
||||
CallRcvr(a) => format!("CallRcvr({})", a.repr(tcx)),
|
||||
CallArg(a) => format!("CallArg({})", a.repr(tcx)),
|
||||
CallReturn(a) => format!("CallReturn({})", a.repr(tcx)),
|
||||
AddrOf(a) => format!("AddrOf({})", a.repr(tcx)),
|
||||
AutoBorrow(a) => format!("AutoBorrow({})", a.repr(tcx)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -962,39 +959,32 @@ impl Repr for RegionVariableOrigin {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
match *self {
|
||||
MiscVariable(a) => {
|
||||
format_strbuf!("MiscVariable({})", a.repr(tcx))
|
||||
format!("MiscVariable({})", a.repr(tcx))
|
||||
}
|
||||
PatternRegion(a) => {
|
||||
format_strbuf!("PatternRegion({})", a.repr(tcx))
|
||||
format!("PatternRegion({})", a.repr(tcx))
|
||||
}
|
||||
AddrOfRegion(a) => {
|
||||
format_strbuf!("AddrOfRegion({})", a.repr(tcx))
|
||||
format!("AddrOfRegion({})", a.repr(tcx))
|
||||
}
|
||||
AddrOfSlice(a) => format_strbuf!("AddrOfSlice({})", a.repr(tcx)),
|
||||
Autoref(a) => format_strbuf!("Autoref({})", a.repr(tcx)),
|
||||
Coercion(ref a) => format_strbuf!("Coercion({})", a.repr(tcx)),
|
||||
AddrOfSlice(a) => format!("AddrOfSlice({})", a.repr(tcx)),
|
||||
Autoref(a) => format!("Autoref({})", a.repr(tcx)),
|
||||
Coercion(ref a) => format!("Coercion({})", a.repr(tcx)),
|
||||
EarlyBoundRegion(a, b) => {
|
||||
format_strbuf!("EarlyBoundRegion({},{})",
|
||||
a.repr(tcx),
|
||||
b.repr(tcx))
|
||||
format!("EarlyBoundRegion({},{})", a.repr(tcx), b.repr(tcx))
|
||||
}
|
||||
LateBoundRegion(a, b) => {
|
||||
format_strbuf!("LateBoundRegion({},{})",
|
||||
a.repr(tcx),
|
||||
b.repr(tcx))
|
||||
format!("LateBoundRegion({},{})", a.repr(tcx), b.repr(tcx))
|
||||
}
|
||||
BoundRegionInFnType(a, b) => {
|
||||
format_strbuf!("bound_regionInFnType({},{})",
|
||||
a.repr(tcx),
|
||||
b.repr(tcx))
|
||||
format!("bound_regionInFnType({},{})", a.repr(tcx),
|
||||
b.repr(tcx))
|
||||
}
|
||||
BoundRegionInCoherence(a) => {
|
||||
format_strbuf!("bound_regionInCoherence({})", a.repr(tcx))
|
||||
format!("bound_regionInCoherence({})", a.repr(tcx))
|
||||
}
|
||||
UpvarRegion(a, b) => {
|
||||
format_strbuf!("UpvarRegion({}, {})",
|
||||
a.repr(tcx),
|
||||
b.repr(tcx))
|
||||
format!("UpvarRegion({}, {})", a.repr(tcx), b.repr(tcx))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1342,24 +1342,16 @@ impl Repr for Constraint {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
match *self {
|
||||
ConstrainVarSubVar(a, b) => {
|
||||
format_strbuf!("ConstrainVarSubVar({}, {})",
|
||||
a.repr(tcx),
|
||||
b.repr(tcx))
|
||||
format!("ConstrainVarSubVar({}, {})", a.repr(tcx), b.repr(tcx))
|
||||
}
|
||||
ConstrainRegSubVar(a, b) => {
|
||||
format_strbuf!("ConstrainRegSubVar({}, {})",
|
||||
a.repr(tcx),
|
||||
b.repr(tcx))
|
||||
format!("ConstrainRegSubVar({}, {})", a.repr(tcx), b.repr(tcx))
|
||||
}
|
||||
ConstrainVarSubReg(a, b) => {
|
||||
format_strbuf!("ConstrainVarSubReg({}, {})",
|
||||
a.repr(tcx),
|
||||
b.repr(tcx))
|
||||
format!("ConstrainVarSubReg({}, {})", a.repr(tcx), b.repr(tcx))
|
||||
}
|
||||
ConstrainRegSubReg(a, b) => {
|
||||
format_strbuf!("ConstrainRegSubReg({}, {})",
|
||||
a.repr(tcx),
|
||||
b.repr(tcx))
|
||||
format!("ConstrainRegSubReg({}, {})", a.repr(tcx), b.repr(tcx))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,12 +31,11 @@ impl InferStr for ty::t {
|
||||
|
||||
impl InferStr for FnSig {
|
||||
fn inf_str(&self, cx: &InferCtxt) -> String {
|
||||
format_strbuf!("({}) -> {}",
|
||||
self.inputs
|
||||
.iter()
|
||||
.map(|a| a.inf_str(cx))
|
||||
.collect::<Vec<String>>().connect(", "),
|
||||
self.output.inf_str(cx))
|
||||
format!("({}) -> {}",
|
||||
self.inputs.iter()
|
||||
.map(|a| a.inf_str(cx))
|
||||
.collect::<Vec<String>>().connect(", "),
|
||||
self.output.inf_str(cx))
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +47,7 @@ impl InferStr for ty::mt {
|
||||
|
||||
impl InferStr for ty::Region {
|
||||
fn inf_str(&self, _cx: &InferCtxt) -> String {
|
||||
format_strbuf!("{:?}", *self)
|
||||
format!("{:?}", *self)
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,18 +62,16 @@ impl<V:InferStr> InferStr for Bound<V> {
|
||||
|
||||
impl<T:InferStr> InferStr for Bounds<T> {
|
||||
fn inf_str(&self, cx: &InferCtxt) -> String {
|
||||
format_strbuf!("\\{{} <: {}\\}",
|
||||
self.lb.inf_str(cx),
|
||||
self.ub.inf_str(cx))
|
||||
format!("\\{{} <: {}\\}", self.lb.inf_str(cx), self.ub.inf_str(cx))
|
||||
}
|
||||
}
|
||||
|
||||
impl<V:Vid + ToStr,T:InferStr> InferStr for VarValue<V, T> {
|
||||
fn inf_str(&self, cx: &InferCtxt) -> String {
|
||||
match *self {
|
||||
Redirect(ref vid) => format_strbuf!("Redirect({})", vid.to_str()),
|
||||
Redirect(ref vid) => format!("Redirect({})", vid.to_str()),
|
||||
Root(ref pt, rk) => {
|
||||
format_strbuf!("Root({}, {})", pt.inf_str(cx), rk)
|
||||
format!("Root({}, {})", pt.inf_str(cx), rk)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -201,15 +201,15 @@ impl Repr for vtable_origin {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
match *self {
|
||||
vtable_static(def_id, ref tys, ref vtable_res) => {
|
||||
format_strbuf!("vtable_static({:?}:{}, {}, {})",
|
||||
def_id,
|
||||
ty::item_path_str(tcx, def_id),
|
||||
tys.repr(tcx),
|
||||
vtable_res.repr(tcx))
|
||||
format!("vtable_static({:?}:{}, {}, {})",
|
||||
def_id,
|
||||
ty::item_path_str(tcx, def_id),
|
||||
tys.repr(tcx),
|
||||
vtable_res.repr(tcx))
|
||||
}
|
||||
|
||||
vtable_param(x, y) => {
|
||||
format_strbuf!("vtable_param({:?}, {:?})", x, y)
|
||||
format!("vtable_param({:?}, {:?})", x, y)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -231,9 +231,9 @@ pub struct impl_res {
|
||||
|
||||
impl Repr for impl_res {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
format_strbuf!("impl_res \\{trait_vtables={}, self_vtables={}\\}",
|
||||
self.trait_vtables.repr(tcx),
|
||||
self.self_vtables.repr(tcx))
|
||||
format!("impl_res \\{trait_vtables={}, self_vtables={}\\}",
|
||||
self.trait_vtables.repr(tcx),
|
||||
self.self_vtables.repr(tcx))
|
||||
}
|
||||
}
|
||||
|
||||
@ -354,8 +354,8 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
|
||||
|
||||
require_same_types(tcx, None, false, main_span, main_t, se_ty,
|
||||
|| {
|
||||
format_strbuf!("main function expects type: `{}`",
|
||||
ppaux::ty_to_str(ccx.tcx, se_ty))
|
||||
format!("main function expects type: `{}`",
|
||||
ppaux::ty_to_str(ccx.tcx, se_ty))
|
||||
});
|
||||
}
|
||||
_ => {
|
||||
@ -407,8 +407,8 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
|
||||
|
||||
require_same_types(tcx, None, false, start_span, start_t, se_ty,
|
||||
|| {
|
||||
format_strbuf!("start function expects type: `{}`",
|
||||
ppaux::ty_to_str(ccx.tcx, se_ty))
|
||||
format!("start function expects type: `{}`",
|
||||
ppaux::ty_to_str(ccx.tcx, se_ty))
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -86,9 +86,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
|
||||
}
|
||||
Some(_) | None => {
|
||||
// this really should not happen
|
||||
(format_strbuf!("unknown scope: {}. Please report a bug.",
|
||||
node_id),
|
||||
None)
|
||||
(format!("unknown scope: {}. Please report a bug.", node_id), None)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -96,29 +94,28 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
|
||||
ReFree(ref fr) => {
|
||||
let prefix = match fr.bound_region {
|
||||
BrAnon(idx) => {
|
||||
format_strbuf!("the anonymous lifetime \\#{} defined on",
|
||||
idx + 1)
|
||||
format!("the anonymous lifetime \\#{} defined on", idx + 1)
|
||||
}
|
||||
BrFresh(_) => "an anonymous lifetime defined on".to_string(),
|
||||
_ => {
|
||||
format_strbuf!("the lifetime {} as defined on",
|
||||
bound_region_ptr_to_str(cx, fr.bound_region))
|
||||
format!("the lifetime {} as defined on",
|
||||
bound_region_ptr_to_str(cx, fr.bound_region))
|
||||
}
|
||||
};
|
||||
|
||||
match cx.map.find(fr.scope_id) {
|
||||
Some(ast_map::NodeBlock(ref blk)) => {
|
||||
let (msg, opt_span) = explain_span(cx, "block", blk.span);
|
||||
(format_strbuf!("{} {}", prefix, msg), opt_span)
|
||||
(format!("{} {}", prefix, msg), opt_span)
|
||||
}
|
||||
Some(ast_map::NodeItem(it)) if match it.node {
|
||||
ast::ItemImpl(..) => true, _ => false} => {
|
||||
let (msg, opt_span) = explain_span(cx, "impl", it.span);
|
||||
(format_strbuf!("{} {}", prefix, msg), opt_span)
|
||||
(format!("{} {}", prefix, msg), opt_span)
|
||||
}
|
||||
Some(_) | None => {
|
||||
// this really should not happen
|
||||
(format_strbuf!("{} node {}", prefix, fr.scope_id), None)
|
||||
(format!("{} node {}", prefix, fr.scope_id), None)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,17 +127,15 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
|
||||
// I believe these cases should not occur (except when debugging,
|
||||
// perhaps)
|
||||
ty::ReInfer(_) | ty::ReEarlyBound(..) | ty::ReLateBound(..) => {
|
||||
(format_strbuf!("lifetime {:?}", region), None)
|
||||
(format!("lifetime {:?}", region), None)
|
||||
}
|
||||
};
|
||||
|
||||
fn explain_span(cx: &ctxt, heading: &str, span: Span)
|
||||
-> (String, Option<Span>) {
|
||||
let lo = cx.sess.codemap().lookup_char_pos_adj(span.lo);
|
||||
(format_strbuf!("the {} at {}:{}",
|
||||
heading,
|
||||
lo.line,
|
||||
lo.col.to_uint()), Some(span))
|
||||
(format!("the {} at {}:{}", heading, lo.line, lo.col.to_uint()),
|
||||
Some(span))
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,15 +149,12 @@ pub fn bound_region_to_str(cx: &ctxt,
|
||||
let space_str = if space { " " } else { "" };
|
||||
|
||||
if cx.sess.verbose() {
|
||||
return format_strbuf!("{}{}{}", prefix, br.repr(cx), space_str)
|
||||
return format!("{}{}{}", prefix, br.repr(cx), space_str)
|
||||
}
|
||||
|
||||
match br {
|
||||
BrNamed(_, name) => {
|
||||
format_strbuf!("{}'{}{}",
|
||||
prefix,
|
||||
token::get_name(name),
|
||||
space_str)
|
||||
format!("{}'{}{}", prefix, token::get_name(name), space_str)
|
||||
}
|
||||
BrAnon(_) => prefix.to_string(),
|
||||
BrFresh(_) => prefix.to_string(),
|
||||
@ -180,7 +172,7 @@ pub fn region_to_str(cx: &ctxt, prefix: &str, space: bool, region: Region) -> St
|
||||
let space_str = if space { " " } else { "" };
|
||||
|
||||
if cx.sess.verbose() {
|
||||
return format_strbuf!("{}{}{}", prefix, region.repr(cx), space_str)
|
||||
return format!("{}{}{}", prefix, region.repr(cx), space_str)
|
||||
}
|
||||
|
||||
// These printouts are concise. They do not contain all the information
|
||||
@ -198,8 +190,8 @@ pub fn region_to_str(cx: &ctxt, prefix: &str, space: bool, region: Region) -> St
|
||||
bound_region_to_str(cx, prefix, space, br)
|
||||
}
|
||||
ty::ReInfer(ReVar(_)) => prefix.to_string(),
|
||||
ty::ReStatic => format_strbuf!("{}'static{}", prefix, space_str),
|
||||
ty::ReEmpty => format_strbuf!("{}'<empty>{}", prefix, space_str),
|
||||
ty::ReStatic => format!("{}'static{}", prefix, space_str),
|
||||
ty::ReEmpty => format!("{}'<empty>{}", prefix, space_str),
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,30 +203,26 @@ pub fn mutability_to_str(m: ast::Mutability) -> String {
|
||||
}
|
||||
|
||||
pub fn mt_to_str(cx: &ctxt, m: &mt) -> String {
|
||||
format_strbuf!("{}{}", mutability_to_str(m.mutbl), ty_to_str(cx, m.ty))
|
||||
format!("{}{}", mutability_to_str(m.mutbl), ty_to_str(cx, m.ty))
|
||||
}
|
||||
|
||||
pub fn trait_store_to_str(cx: &ctxt, s: ty::TraitStore) -> String {
|
||||
match s {
|
||||
ty::UniqTraitStore => "Box ".to_string(),
|
||||
ty::RegionTraitStore(r, m) => {
|
||||
format_strbuf!("{}{}",
|
||||
region_ptr_to_str(cx, r),
|
||||
mutability_to_str(m))
|
||||
format!("{}{}", region_ptr_to_str(cx, r), mutability_to_str(m))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn vec_map_to_str<T>(ts: &[T], f: |t: &T| -> String) -> String {
|
||||
let tstrs = ts.iter().map(f).collect::<Vec<String>>();
|
||||
format_strbuf!("[{}]", tstrs.connect(", "))
|
||||
format!("[{}]", tstrs.connect(", "))
|
||||
}
|
||||
|
||||
pub fn fn_sig_to_str(cx: &ctxt, typ: &ty::FnSig) -> String {
|
||||
format_strbuf!("fn{}{} -> {}",
|
||||
typ.binder_id,
|
||||
typ.inputs.repr(cx),
|
||||
typ.output.repr(cx))
|
||||
format!("fn{}{} -> {}", typ.binder_id, typ.inputs.repr(cx),
|
||||
typ.output.repr(cx))
|
||||
}
|
||||
|
||||
pub fn trait_ref_to_str(cx: &ctxt, trait_ref: &ty::TraitRef) -> String {
|
||||
@ -360,9 +348,9 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> String {
|
||||
ty_uint(t) => ast_util::uint_ty_to_str(t, None,
|
||||
ast_util::AutoSuffix).to_string(),
|
||||
ty_float(t) => ast_util::float_ty_to_str(t).to_string(),
|
||||
ty_box(typ) => format_strbuf!("@{}", ty_to_str(cx, typ)),
|
||||
ty_uniq(typ) => format_strbuf!("~{}", ty_to_str(cx, typ)),
|
||||
ty_ptr(ref tm) => format_strbuf!("*{}", mt_to_str(cx, tm)),
|
||||
ty_box(typ) => format!("@{}", ty_to_str(cx, typ)),
|
||||
ty_uniq(typ) => format!("~{}", ty_to_str(cx, typ)),
|
||||
ty_ptr(ref tm) => format!("*{}", mt_to_str(cx, tm)),
|
||||
ty_rptr(r, ref tm) => {
|
||||
let mut buf = region_ptr_to_str(cx, r);
|
||||
buf.push_str(mt_to_str(cx, tm).as_slice());
|
||||
@ -370,7 +358,7 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> String {
|
||||
}
|
||||
ty_tup(ref elems) => {
|
||||
let strs: Vec<String> = elems.iter().map(|elem| ty_to_str(cx, *elem)).collect();
|
||||
format_strbuf!("({})", strs.connect(","))
|
||||
format!("({})", strs.connect(","))
|
||||
}
|
||||
ty_closure(ref f) => {
|
||||
closure_to_str(cx, *f)
|
||||
@ -385,12 +373,12 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> String {
|
||||
Some(def) => token::get_ident(def.ident).get().to_string(),
|
||||
// This can only happen when a type mismatch error happens and
|
||||
// the actual type has more type parameters than the expected one.
|
||||
None => format_strbuf!("<generic \\#{}>", id)
|
||||
None => format!("<generic \\#{}>", id)
|
||||
};
|
||||
if !cx.sess.verbose() {
|
||||
ident
|
||||
} else {
|
||||
format_strbuf!("{}:{:?}", ident, did)
|
||||
format!("{}:{:?}", ident, did)
|
||||
}
|
||||
}
|
||||
ty_self(..) => "Self".to_string(),
|
||||
@ -411,19 +399,19 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> String {
|
||||
substs.tps.as_slice(), did, true);
|
||||
let bound_sep = if bounds.is_empty() { "" } else { ":" };
|
||||
let bound_str = bounds.repr(cx);
|
||||
format_strbuf!("{}{}{}{}",
|
||||
trait_store_to_str(cx, store),
|
||||
ty,
|
||||
bound_sep,
|
||||
bound_str)
|
||||
format!("{}{}{}{}",
|
||||
trait_store_to_str(cx, store),
|
||||
ty,
|
||||
bound_sep,
|
||||
bound_str)
|
||||
}
|
||||
ty_str => "str".to_string(),
|
||||
ty_vec(ref mt, sz) => {
|
||||
match sz {
|
||||
Some(n) => {
|
||||
format_strbuf!("[{}, .. {}]", mt_to_str(cx, mt), n)
|
||||
format!("[{}, .. {}]", mt_to_str(cx, mt), n)
|
||||
}
|
||||
None => format_strbuf!("[{}]", ty_to_str(cx, mt.ty)),
|
||||
None => format!("[{}]", ty_to_str(cx, mt.ty)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -476,9 +464,9 @@ pub fn parameterized(cx: &ctxt,
|
||||
}
|
||||
|
||||
if strs.len() > 0u {
|
||||
format_strbuf!("{}<{}>", base, strs.connect(","))
|
||||
format!("{}<{}>", base, strs.connect(","))
|
||||
} else {
|
||||
format_strbuf!("{}", base)
|
||||
format!("{}", base)
|
||||
}
|
||||
}
|
||||
|
||||
@ -503,7 +491,7 @@ impl<T:Repr,U:Repr> Repr for Result<T,U> {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
match self {
|
||||
&Ok(ref t) => t.repr(tcx),
|
||||
&Err(ref u) => format_strbuf!("Err({})", u.repr(tcx))
|
||||
&Err(ref u) => format!("Err({})", u.repr(tcx))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -558,17 +546,16 @@ impl<T:Repr> Repr for Vec<T> {
|
||||
|
||||
impl Repr for ty::TypeParameterDef {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
format_strbuf!("TypeParameterDef({:?}, {})",
|
||||
self.def_id,
|
||||
self.bounds.repr(tcx))
|
||||
format!("TypeParameterDef({:?}, {})", self.def_id,
|
||||
self.bounds.repr(tcx))
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::RegionParameterDef {
|
||||
fn repr(&self, _tcx: &ctxt) -> String {
|
||||
format_strbuf!("RegionParameterDef({}, {:?})",
|
||||
token::get_name(self.name),
|
||||
self.def_id)
|
||||
format!("RegionParameterDef({}, {:?})",
|
||||
token::get_name(self.name),
|
||||
self.def_id)
|
||||
}
|
||||
}
|
||||
|
||||
@ -580,16 +567,16 @@ impl Repr for ty::t {
|
||||
|
||||
impl Repr for ty::substs {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
format_strbuf!("substs(regions={}, self_ty={}, tps={})",
|
||||
self.regions.repr(tcx),
|
||||
self.self_ty.repr(tcx),
|
||||
self.tps.repr(tcx))
|
||||
format!("substs(regions={}, self_ty={}, tps={})",
|
||||
self.regions.repr(tcx),
|
||||
self.self_ty.repr(tcx),
|
||||
self.tps.repr(tcx))
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::ItemSubsts {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
format_strbuf!("ItemSubsts({})", self.substs.repr(tcx))
|
||||
format!("ItemSubsts({})", self.substs.repr(tcx))
|
||||
}
|
||||
}
|
||||
|
||||
@ -629,40 +616,38 @@ impl Repr for ty::TraitRef {
|
||||
|
||||
impl Repr for ast::Expr {
|
||||
fn repr(&self, _tcx: &ctxt) -> String {
|
||||
format_strbuf!("expr({}: {})", self.id, pprust::expr_to_str(self))
|
||||
format!("expr({}: {})", self.id, pprust::expr_to_str(self))
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ast::Item {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
format_strbuf!("item({})", tcx.map.node_to_str(self.id))
|
||||
format!("item({})", tcx.map.node_to_str(self.id))
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ast::Stmt {
|
||||
fn repr(&self, _tcx: &ctxt) -> String {
|
||||
format_strbuf!("stmt({}: {})",
|
||||
ast_util::stmt_id(self),
|
||||
pprust::stmt_to_str(self))
|
||||
format!("stmt({}: {})",
|
||||
ast_util::stmt_id(self),
|
||||
pprust::stmt_to_str(self))
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ast::Pat {
|
||||
fn repr(&self, _tcx: &ctxt) -> String {
|
||||
format_strbuf!("pat({}: {})", self.id, pprust::pat_to_str(self))
|
||||
format!("pat({}: {})", self.id, pprust::pat_to_str(self))
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::BoundRegion {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
match *self {
|
||||
ty::BrAnon(id) => format_strbuf!("BrAnon({})", id),
|
||||
ty::BrAnon(id) => format!("BrAnon({})", id),
|
||||
ty::BrNamed(id, name) => {
|
||||
format_strbuf!("BrNamed({}, {})",
|
||||
id.repr(tcx),
|
||||
token::get_name(name))
|
||||
format!("BrNamed({}, {})", id.repr(tcx), token::get_name(name))
|
||||
}
|
||||
ty::BrFresh(id) => format_strbuf!("BrFresh({})", id),
|
||||
ty::BrFresh(id) => format!("BrFresh({})", id),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -671,26 +656,26 @@ impl Repr for ty::Region {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
match *self {
|
||||
ty::ReEarlyBound(id, index, name) => {
|
||||
format_strbuf!("ReEarlyBound({}, {}, {})",
|
||||
id,
|
||||
index,
|
||||
token::get_name(name))
|
||||
format!("ReEarlyBound({}, {}, {})",
|
||||
id,
|
||||
index,
|
||||
token::get_name(name))
|
||||
}
|
||||
|
||||
ty::ReLateBound(binder_id, ref bound_region) => {
|
||||
format_strbuf!("ReLateBound({}, {})",
|
||||
binder_id,
|
||||
bound_region.repr(tcx))
|
||||
format!("ReLateBound({}, {})",
|
||||
binder_id,
|
||||
bound_region.repr(tcx))
|
||||
}
|
||||
|
||||
ty::ReFree(ref fr) => {
|
||||
format_strbuf!("ReFree({}, {})",
|
||||
fr.scope_id,
|
||||
fr.bound_region.repr(tcx))
|
||||
format!("ReFree({}, {})",
|
||||
fr.scope_id,
|
||||
fr.bound_region.repr(tcx))
|
||||
}
|
||||
|
||||
ty::ReScope(id) => {
|
||||
format_strbuf!("ReScope({})", id)
|
||||
format!("ReScope({})", id)
|
||||
}
|
||||
|
||||
ty::ReStatic => {
|
||||
@ -698,11 +683,11 @@ impl Repr for ty::Region {
|
||||
}
|
||||
|
||||
ty::ReInfer(ReVar(ref vid)) => {
|
||||
format_strbuf!("ReInfer({})", vid.id)
|
||||
format!("ReInfer({})", vid.id)
|
||||
}
|
||||
|
||||
ty::ReInfer(ReSkolemized(id, ref bound_region)) => {
|
||||
format_strbuf!("re_skolemized({}, {})",
|
||||
format!("re_skolemized({}, {})",
|
||||
id,
|
||||
bound_region.repr(tcx))
|
||||
}
|
||||
@ -728,7 +713,7 @@ impl Repr for ast::DefId {
|
||||
Some(ast_map::NodeTraitMethod(..)) |
|
||||
Some(ast_map::NodeVariant(..)) |
|
||||
Some(ast_map::NodeStructCtor(..)) => {
|
||||
return format_strbuf!(
|
||||
return format!(
|
||||
"{:?}:{}",
|
||||
*self,
|
||||
ty::item_path_str(tcx, *self))
|
||||
@ -737,35 +722,32 @@ impl Repr for ast::DefId {
|
||||
}
|
||||
}
|
||||
}
|
||||
return format_strbuf!("{:?}", *self)
|
||||
return format!("{:?}", *self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::ty_param_bounds_and_ty {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
format_strbuf!("ty_param_bounds_and_ty \\{generics: {}, ty: {}\\}",
|
||||
self.generics.repr(tcx),
|
||||
self.ty.repr(tcx))
|
||||
format!("ty_param_bounds_and_ty \\{generics: {}, ty: {}\\}",
|
||||
self.generics.repr(tcx),
|
||||
self.ty.repr(tcx))
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::Generics {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
format_strbuf!("Generics(type_param_defs: {}, \
|
||||
region_param_defs: {})",
|
||||
self.type_param_defs().repr(tcx),
|
||||
self.region_param_defs().repr(tcx))
|
||||
format!("Generics(type_param_defs: {}, region_param_defs: {})",
|
||||
self.type_param_defs().repr(tcx),
|
||||
self.region_param_defs().repr(tcx))
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::ItemVariances {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
format_strbuf!("IterVariances(self_param={}, \
|
||||
type_params={}, \
|
||||
region_params={})",
|
||||
self.self_param.repr(tcx),
|
||||
self.type_params.repr(tcx),
|
||||
self.region_params.repr(tcx))
|
||||
format!("IterVariances(self_param={}, type_params={}, region_params={})",
|
||||
self.self_param.repr(tcx),
|
||||
self.type_params.repr(tcx),
|
||||
self.region_params.repr(tcx))
|
||||
}
|
||||
}
|
||||
|
||||
@ -777,14 +759,14 @@ impl Repr for ty::Variance {
|
||||
|
||||
impl Repr for ty::Method {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
format_strbuf!("method(ident: {}, generics: {}, fty: {}, \
|
||||
explicit_self: {}, vis: {}, def_id: {})",
|
||||
self.ident.repr(tcx),
|
||||
self.generics.repr(tcx),
|
||||
self.fty.repr(tcx),
|
||||
self.explicit_self.repr(tcx),
|
||||
self.vis.repr(tcx),
|
||||
self.def_id.repr(tcx))
|
||||
format!("method(ident: {}, generics: {}, fty: {}, \
|
||||
explicit_self: {}, vis: {}, def_id: {})",
|
||||
self.ident.repr(tcx),
|
||||
self.generics.repr(tcx),
|
||||
self.fty.repr(tcx),
|
||||
self.explicit_self.repr(tcx),
|
||||
self.vis.repr(tcx),
|
||||
self.def_id.repr(tcx))
|
||||
}
|
||||
}
|
||||
|
||||
@ -802,22 +784,22 @@ impl Repr for ast::Ident {
|
||||
|
||||
impl Repr for ast::ExplicitSelf_ {
|
||||
fn repr(&self, _tcx: &ctxt) -> String {
|
||||
format_strbuf!("{:?}", *self)
|
||||
format!("{:?}", *self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ast::Visibility {
|
||||
fn repr(&self, _tcx: &ctxt) -> String {
|
||||
format_strbuf!("{:?}", *self)
|
||||
format!("{:?}", *self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::BareFnTy {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
format_strbuf!("BareFnTy \\{fn_style: {:?}, abi: {}, sig: {}\\}",
|
||||
self.fn_style,
|
||||
self.abi.to_str(),
|
||||
self.sig.repr(tcx))
|
||||
format!("BareFnTy \\{fn_style: {:?}, abi: {}, sig: {}\\}",
|
||||
self.fn_style,
|
||||
self.abi.to_str(),
|
||||
self.sig.repr(tcx))
|
||||
}
|
||||
}
|
||||
|
||||
@ -829,10 +811,10 @@ impl Repr for ty::FnSig {
|
||||
|
||||
impl Repr for typeck::MethodCallee {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
format_strbuf!("MethodCallee \\{origin: {}, ty: {}, {}\\}",
|
||||
self.origin.repr(tcx),
|
||||
self.ty.repr(tcx),
|
||||
self.substs.repr(tcx))
|
||||
format!("MethodCallee \\{origin: {}, ty: {}, {}\\}",
|
||||
self.origin.repr(tcx),
|
||||
self.ty.repr(tcx),
|
||||
self.substs.repr(tcx))
|
||||
}
|
||||
}
|
||||
|
||||
@ -840,7 +822,7 @@ impl Repr for typeck::MethodOrigin {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
match self {
|
||||
&typeck::MethodStatic(def_id) => {
|
||||
format_strbuf!("MethodStatic({})", def_id.repr(tcx))
|
||||
format!("MethodStatic({})", def_id.repr(tcx))
|
||||
}
|
||||
&typeck::MethodParam(ref p) => {
|
||||
p.repr(tcx)
|
||||
@ -854,27 +836,27 @@ impl Repr for typeck::MethodOrigin {
|
||||
|
||||
impl Repr for typeck::MethodParam {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
format_strbuf!("MethodParam({},{:?},{:?},{:?})",
|
||||
self.trait_id.repr(tcx),
|
||||
self.method_num,
|
||||
self.param_num,
|
||||
self.bound_num)
|
||||
format!("MethodParam({},{:?},{:?},{:?})",
|
||||
self.trait_id.repr(tcx),
|
||||
self.method_num,
|
||||
self.param_num,
|
||||
self.bound_num)
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for typeck::MethodObject {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
format_strbuf!("MethodObject({},{:?},{:?})",
|
||||
self.trait_id.repr(tcx),
|
||||
self.method_num,
|
||||
self.real_index)
|
||||
format!("MethodObject({},{:?},{:?})",
|
||||
self.trait_id.repr(tcx),
|
||||
self.method_num,
|
||||
self.real_index)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl Repr for ty::RegionVid {
|
||||
fn repr(&self, _tcx: &ctxt) -> String {
|
||||
format_strbuf!("{:?}", *self)
|
||||
format!("{:?}", *self)
|
||||
}
|
||||
}
|
||||
|
||||
@ -886,7 +868,7 @@ impl Repr for ty::TraitStore {
|
||||
|
||||
impl Repr for ty::BuiltinBound {
|
||||
fn repr(&self, _tcx: &ctxt) -> String {
|
||||
format_strbuf!("{:?}", *self)
|
||||
format!("{:?}", *self)
|
||||
}
|
||||
}
|
||||
|
||||
@ -980,29 +962,29 @@ impl UserString for abi::Abi {
|
||||
|
||||
impl Repr for ty::UpvarId {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
format_strbuf!("UpvarId({};`{}`;{})",
|
||||
self.var_id,
|
||||
ty::local_var_name_str(tcx, self.var_id),
|
||||
self.closure_expr_id)
|
||||
format!("UpvarId({};`{}`;{})",
|
||||
self.var_id,
|
||||
ty::local_var_name_str(tcx, self.var_id),
|
||||
self.closure_expr_id)
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ast::Mutability {
|
||||
fn repr(&self, _tcx: &ctxt) -> String {
|
||||
format_strbuf!("{:?}", *self)
|
||||
format!("{:?}", *self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::BorrowKind {
|
||||
fn repr(&self, _tcx: &ctxt) -> String {
|
||||
format_strbuf!("{:?}", *self)
|
||||
format!("{:?}", *self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Repr for ty::UpvarBorrow {
|
||||
fn repr(&self, tcx: &ctxt) -> String {
|
||||
format_strbuf!("UpvarBorrow({}, {})",
|
||||
self.kind.repr(tcx),
|
||||
self.region.repr(tcx))
|
||||
format!("UpvarBorrow({}, {})",
|
||||
self.kind.repr(tcx),
|
||||
self.region.repr(tcx))
|
||||
}
|
||||
}
|
||||
|
@ -1000,7 +1000,7 @@ impl Clean<Type> for ty::t {
|
||||
ty::ty_str => String,
|
||||
ty::ty_vec(mt, None) => Vector(box mt.ty.clean()),
|
||||
ty::ty_vec(mt, Some(i)) => FixedVector(box mt.ty.clean(),
|
||||
format_strbuf!("{}", i)),
|
||||
format!("{}", i)),
|
||||
ty::ty_ptr(mt) => RawPointer(mt.mutbl.clean(), box mt.ty.clean()),
|
||||
ty::ty_rptr(r, mt) => BorrowedRef {
|
||||
lifetime: r.clean(),
|
||||
@ -1697,8 +1697,8 @@ impl ToSource for syntax::codemap::Span {
|
||||
fn lit_to_str(lit: &ast::Lit) -> String {
|
||||
match lit.node {
|
||||
ast::LitStr(ref st, _) => st.get().to_string(),
|
||||
ast::LitBinary(ref data) => format_strbuf!("{:?}", data.as_slice()),
|
||||
ast::LitChar(c) => format_strbuf!("'{}'", c),
|
||||
ast::LitBinary(ref data) => format!("{:?}", data.as_slice()),
|
||||
ast::LitChar(c) => format!("'{}'", c),
|
||||
ast::LitInt(i, _t) => i.to_str().to_string(),
|
||||
ast::LitUint(u, _t) => u.to_str().to_string(),
|
||||
ast::LitIntUnsuffixed(i) => i.to_str().to_string(),
|
||||
@ -1817,7 +1817,7 @@ pub struct Macro {
|
||||
impl Clean<Item> for doctree::Macro {
|
||||
fn clean(&self) -> Item {
|
||||
Item {
|
||||
name: Some(format_strbuf!("{}!", self.name.clean())),
|
||||
name: Some(format!("{}!", self.name.clean())),
|
||||
attrs: self.attrs.clean(),
|
||||
source: self.where.clean(),
|
||||
visibility: ast::Public.clean(),
|
||||
|
@ -366,7 +366,7 @@ impl fmt::Show for clean::Type {
|
||||
lifetimes = if decl.lifetimes.len() == 0 {
|
||||
"".to_string()
|
||||
} else {
|
||||
format_strbuf!("<{:#}>", decl.lifetimes)
|
||||
format!("<{:#}>", decl.lifetimes)
|
||||
},
|
||||
args = decl.decl.inputs,
|
||||
bounds = if decl.bounds.len() == 0 {
|
||||
@ -375,7 +375,7 @@ impl fmt::Show for clean::Type {
|
||||
let mut m = decl.bounds
|
||||
.iter()
|
||||
.map(|s| s.to_str().to_string());
|
||||
format_strbuf!(
|
||||
format!(
|
||||
": {}",
|
||||
m.collect::<Vec<String>>().connect(" + "))
|
||||
},
|
||||
@ -388,7 +388,7 @@ impl fmt::Show for clean::Type {
|
||||
match decl.abi.as_slice() {
|
||||
"" => " extern ".to_string(),
|
||||
"\"Rust\"" => "".to_string(),
|
||||
s => format_strbuf!(" extern {} ", s)
|
||||
s => format!(" extern {} ", s)
|
||||
},
|
||||
decl.generics,
|
||||
decl.decl)
|
||||
|
@ -223,7 +223,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
|
||||
let map = used_header_map.get().unwrap();
|
||||
let id = match map.borrow_mut().find_mut(&id) {
|
||||
None => id,
|
||||
Some(a) => { *a += 1; format_strbuf!("{}-{}", id, *a - 1) }
|
||||
Some(a) => { *a += 1; format!("{}-{}", id, *a - 1) }
|
||||
};
|
||||
map.borrow_mut().insert(id.clone(), 1);
|
||||
|
||||
|
@ -578,7 +578,7 @@ fn extern_location(e: &clean::ExternalCrate, dst: &Path) -> ExternalLocation {
|
||||
if s.as_slice().ends_with("/") {
|
||||
return Remote(s.to_string());
|
||||
}
|
||||
return Remote(format_strbuf!("{}/", s));
|
||||
return Remote(format!("{}/", s));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@ -1187,12 +1187,12 @@ impl<'a> fmt::Show for Item<'a> {
|
||||
fn item_path(item: &clean::Item) -> String {
|
||||
match item.inner {
|
||||
clean::ModuleItem(..) => {
|
||||
format_strbuf!("{}/index.html", item.name.get_ref())
|
||||
format!("{}/index.html", item.name.get_ref())
|
||||
}
|
||||
_ => {
|
||||
format_strbuf!("{}.{}.html",
|
||||
shortty(item).to_static_str(),
|
||||
*item.name.get_ref())
|
||||
format!("{}.{}.html",
|
||||
shortty(item).to_static_str(),
|
||||
*item.name.get_ref())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ impl TocBuilder {
|
||||
sec_number.push_str("0.");
|
||||
}
|
||||
let number = toc.count_entries_with_level(level);
|
||||
sec_number.push_str(format_strbuf!("{}", number + 1).as_slice())
|
||||
sec_number.push_str(format!("{}", number + 1).as_slice())
|
||||
}
|
||||
|
||||
self.chain.push(TocEntry {
|
||||
|
@ -248,7 +248,7 @@ fn acquire_input(input: &str,
|
||||
match matches.opt_str("r").as_ref().map(|s| s.as_slice()) {
|
||||
Some("rust") => Ok(rust_input(input, matches)),
|
||||
Some("json") => json_input(input),
|
||||
Some(s) => Err(format_strbuf!("unknown input format: {}", s)),
|
||||
Some(s) => Err(format!("unknown input format: {}", s)),
|
||||
None => {
|
||||
if input.ends_with(".json") {
|
||||
json_input(input)
|
||||
@ -356,7 +356,7 @@ fn json_input(input: &str) -> Result<Output, String> {
|
||||
let mut input = match File::open(&Path::new(input)) {
|
||||
Ok(f) => f,
|
||||
Err(e) => {
|
||||
return Err(format_strbuf!("couldn't open {}: {}", input, e))
|
||||
return Err(format!("couldn't open {}: {}", input, e))
|
||||
}
|
||||
};
|
||||
match json::from_reader(&mut input) {
|
||||
@ -367,7 +367,7 @@ fn json_input(input: &str) -> Result<Output, String> {
|
||||
match obj.pop(&"schema".to_string()) {
|
||||
Some(json::String(version)) => {
|
||||
if version.as_slice() != SCHEMA_VERSION {
|
||||
return Err(format_strbuf!(
|
||||
return Err(format!(
|
||||
"sorry, but I only understand version {}",
|
||||
SCHEMA_VERSION))
|
||||
}
|
||||
|
@ -260,9 +260,9 @@ impl Collector {
|
||||
pub fn add_test(&mut self, test: String, should_fail: bool, no_run: bool, should_ignore: bool) {
|
||||
let name = if self.use_headers {
|
||||
let s = self.current_header.as_ref().map(|s| s.as_slice()).unwrap_or("");
|
||||
format_strbuf!("{}_{}", s, self.cnt)
|
||||
format!("{}_{}", s, self.cnt)
|
||||
} else {
|
||||
format_strbuf!("{}_{}", self.names.connect("::"), self.cnt)
|
||||
format!("{}_{}", self.names.connect("::"), self.cnt)
|
||||
};
|
||||
self.cnt += 1;
|
||||
let libs = self.libs.clone();
|
||||
|
@ -377,13 +377,13 @@ fn test_ne() {
|
||||
|
||||
#[test]
|
||||
fn test_show() {
|
||||
assert_eq!(format_strbuf!("{}", parse("1.2.3").unwrap()),
|
||||
assert_eq!(format!("{}", parse("1.2.3").unwrap()),
|
||||
"1.2.3".to_string());
|
||||
assert_eq!(format_strbuf!("{}", parse("1.2.3-alpha1").unwrap()),
|
||||
assert_eq!(format!("{}", parse("1.2.3-alpha1").unwrap()),
|
||||
"1.2.3-alpha1".to_string());
|
||||
assert_eq!(format_strbuf!("{}", parse("1.2.3+build.42").unwrap()),
|
||||
assert_eq!(format!("{}", parse("1.2.3+build.42").unwrap()),
|
||||
"1.2.3+build.42".to_string());
|
||||
assert_eq!(format_strbuf!("{}", parse("1.2.3-alpha1+42").unwrap()),
|
||||
assert_eq!(format!("{}", parse("1.2.3-alpha1+42").unwrap()),
|
||||
"1.2.3-alpha1+42".to_string());
|
||||
}
|
||||
|
||||
|
@ -313,10 +313,8 @@ pub mod reader {
|
||||
self.pos = r_doc.end;
|
||||
let str = r_doc.as_str_slice();
|
||||
if lbl != str {
|
||||
return Err(Expected(format_strbuf!("Expected label \
|
||||
{} but found {}",
|
||||
lbl,
|
||||
str)));
|
||||
return Err(Expected(format!("Expected label {} but \
|
||||
found {}", lbl, str)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -326,8 +324,8 @@ pub mod reader {
|
||||
fn next_doc(&mut self, exp_tag: EbmlEncoderTag) -> DecodeResult<Doc<'doc>> {
|
||||
debug!(". next_doc(exp_tag={})", exp_tag);
|
||||
if self.pos >= self.parent.end {
|
||||
return Err(Expected(format_strbuf!("no more documents in \
|
||||
current node!")));
|
||||
return Err(Expected(format!("no more documents in \
|
||||
current node!")));
|
||||
}
|
||||
let TaggedDoc { tag: r_tag, doc: r_doc } =
|
||||
try!(doc_at(self.parent.data, self.pos));
|
||||
@ -339,18 +337,13 @@ pub mod reader {
|
||||
r_doc.start,
|
||||
r_doc.end);
|
||||
if r_tag != (exp_tag as uint) {
|
||||
return Err(Expected(format_strbuf!("expected EBML doc with \
|
||||
tag {} but found tag \
|
||||
{}",
|
||||
exp_tag,
|
||||
r_tag)));
|
||||
return Err(Expected(format!("expected EBML doc with tag {} but \
|
||||
found tag {}", exp_tag, r_tag)));
|
||||
}
|
||||
if r_doc.end > self.parent.end {
|
||||
return Err(Expected(format_strbuf!("invalid EBML, child \
|
||||
extends to {:#x}, parent \
|
||||
to {:#x}",
|
||||
r_doc.end,
|
||||
self.parent.end)));
|
||||
return Err(Expected(format!("invalid EBML, child extends to \
|
||||
{:#x}, parent to {:#x}",
|
||||
r_doc.end, self.parent.end)));
|
||||
}
|
||||
self.pos = r_doc.end;
|
||||
Ok(r_doc)
|
||||
@ -582,8 +575,7 @@ pub mod reader {
|
||||
0 => f(this, false),
|
||||
1 => f(this, true),
|
||||
_ => {
|
||||
Err(Expected(format_strbuf!("Expected None or \
|
||||
Some")))
|
||||
Err(Expected(format!("Expected None or Some")))
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -664,7 +656,7 @@ pub mod writer {
|
||||
_ => Err(io::IoError {
|
||||
kind: io::OtherIoError,
|
||||
desc: "int too big",
|
||||
detail: Some(format_strbuf!("{}", n))
|
||||
detail: Some(format!("{}", n))
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -677,7 +669,7 @@ pub mod writer {
|
||||
Err(io::IoError {
|
||||
kind: io::OtherIoError,
|
||||
desc: "int too big",
|
||||
detail: Some(format_strbuf!("{}", n))
|
||||
detail: Some(format!("{}", n))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -174,8 +174,7 @@ mod tests {
|
||||
#[test]
|
||||
pub fn test_to_hex_all_bytes() {
|
||||
for i in range(0, 256) {
|
||||
assert_eq!([i as u8].to_hex(),
|
||||
format_strbuf!("{:02x}", i as uint));
|
||||
assert_eq!([i as u8].to_hex(), format!("{:02x}", i as uint));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1819,7 +1819,7 @@ macro_rules! expect(
|
||||
match $e {
|
||||
Null => Ok(()),
|
||||
other => Err(ExpectedError("Null".to_string(),
|
||||
format_strbuf!("{}", other)))
|
||||
format!("{}", other)))
|
||||
}
|
||||
});
|
||||
($e:expr, $t:ident) => ({
|
||||
@ -1827,7 +1827,7 @@ macro_rules! expect(
|
||||
$t(v) => Ok(v),
|
||||
other => {
|
||||
Err(ExpectedError(stringify!($t).to_string(),
|
||||
format_strbuf!("{}", other)))
|
||||
format!("{}", other)))
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -1869,7 +1869,7 @@ impl ::Decoder<DecoderError> for Decoder {
|
||||
},
|
||||
value => {
|
||||
Err(ExpectedError("Number".to_string(),
|
||||
format_strbuf!("{}", value)))
|
||||
format!("{}", value)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1887,7 +1887,7 @@ impl ::Decoder<DecoderError> for Decoder {
|
||||
}
|
||||
}
|
||||
Err(ExpectedError("single character string".to_string(),
|
||||
format_strbuf!("{}", s)))
|
||||
format!("{}", s)))
|
||||
}
|
||||
|
||||
fn read_str(&mut self) -> DecodeResult<String> {
|
||||
@ -1914,7 +1914,7 @@ impl ::Decoder<DecoderError> for Decoder {
|
||||
Some(String(s)) => s,
|
||||
Some(val) => {
|
||||
return Err(ExpectedError("String".to_string(),
|
||||
format_strbuf!("{}", val)))
|
||||
format!("{}", val)))
|
||||
}
|
||||
None => {
|
||||
return Err(MissingFieldError("variant".to_string()))
|
||||
@ -1928,7 +1928,7 @@ impl ::Decoder<DecoderError> for Decoder {
|
||||
},
|
||||
Some(val) => {
|
||||
return Err(ExpectedError("List".to_string(),
|
||||
format_strbuf!("{}", val)))
|
||||
format!("{}", val)))
|
||||
}
|
||||
None => {
|
||||
return Err(MissingFieldError("fields".to_string()))
|
||||
@ -1938,7 +1938,7 @@ impl ::Decoder<DecoderError> for Decoder {
|
||||
}
|
||||
json => {
|
||||
return Err(ExpectedError("String or Object".to_string(),
|
||||
format_strbuf!("{}", json)))
|
||||
format!("{}", json)))
|
||||
}
|
||||
};
|
||||
let idx = match names.iter()
|
||||
|
@ -783,6 +783,6 @@ mod tests {
|
||||
#[test]
|
||||
fn test_show() {
|
||||
let c = Ascii { chr: 't' as u8 };
|
||||
assert_eq!(format_strbuf!("{}", c), "t".to_string());
|
||||
assert_eq!(format!("{}", c), "t".to_string());
|
||||
}
|
||||
}
|
||||
|
@ -562,13 +562,6 @@ pub fn format(args: &Arguments) -> string::String{
|
||||
str::from_utf8(output.unwrap().as_slice()).unwrap().into_string()
|
||||
}
|
||||
|
||||
/// Temporary transition utility
|
||||
pub fn format_strbuf(args: &Arguments) -> string::String {
|
||||
let mut output = io::MemWriter::new();
|
||||
let _ = write!(&mut output, "{}", args);
|
||||
str::from_utf8(output.unwrap().as_slice()).unwrap().into_string()
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<T> Poly for T {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||
|
@ -745,8 +745,7 @@ mod test {
|
||||
pub fn tmpdir() -> TempDir {
|
||||
use os;
|
||||
use rand;
|
||||
let ret = os::tmpdir().join(
|
||||
format_strbuf!("rust-{}", rand::random::<u32>()));
|
||||
let ret = os::tmpdir().join(format!("rust-{}", rand::random::<u32>()));
|
||||
check!(io::fs::mkdir(&ret, io::UserRWX));
|
||||
TempDir(ret)
|
||||
}
|
||||
@ -953,7 +952,7 @@ mod test {
|
||||
check!(mkdir(dir, io::UserRWX));
|
||||
let prefix = "foo";
|
||||
for n in range(0,3) {
|
||||
let f = dir.join(format_strbuf!("{}.txt", n));
|
||||
let f = dir.join(format!("{}.txt", n));
|
||||
let mut w = check!(File::create(&f));
|
||||
let msg_str = format!("{}{}", prefix, n.to_str());
|
||||
let msg = msg_str.as_slice().as_bytes();
|
||||
@ -1040,7 +1039,7 @@ mod test {
|
||||
let tmpdir = tmpdir();
|
||||
|
||||
let mut dirpath = tmpdir.path().clone();
|
||||
dirpath.push(format_strbuf!("test-가一ー你好"));
|
||||
dirpath.push(format!("test-가一ー你好"));
|
||||
check!(mkdir(&dirpath, io::UserRWX));
|
||||
assert!(dirpath.is_dir());
|
||||
|
||||
@ -1057,7 +1056,7 @@ mod test {
|
||||
|
||||
let tmpdir = tmpdir();
|
||||
let unicode = tmpdir.path();
|
||||
let unicode = unicode.join(format_strbuf!("test-각丁ー再见"));
|
||||
let unicode = unicode.join(format!("test-각丁ー再见"));
|
||||
check!(mkdir(&unicode, io::UserRWX));
|
||||
assert!(unicode.exists());
|
||||
assert!(!Path::new("test/unicode-bogus-path-각丁ー再见").exists());
|
||||
|
@ -43,10 +43,10 @@ impl TempDir {
|
||||
|
||||
for _ in range(0u, 1000) {
|
||||
let filename =
|
||||
format_strbuf!("rs-{}-{}-{}",
|
||||
unsafe { libc::getpid() },
|
||||
unsafe { CNT.fetch_add(1, atomics::SeqCst) },
|
||||
suffix);
|
||||
format!("rs-{}-{}-{}",
|
||||
unsafe { libc::getpid() },
|
||||
unsafe { CNT.fetch_add(1, atomics::SeqCst) },
|
||||
suffix);
|
||||
let p = tmpdir.join(filename);
|
||||
match fs::mkdir(&p, io::UserRWX) {
|
||||
Err(..) => {}
|
||||
|
@ -67,14 +67,14 @@ pub fn next_test_unix() -> Path {
|
||||
// base port and pid are an attempt to be unique between multiple
|
||||
// test-runners of different configurations running on one
|
||||
// buildbot, the count is to be unique within this executable.
|
||||
let string = format_strbuf!("rust-test-unix-path-{}-{}-{}",
|
||||
base_port(),
|
||||
unsafe {libc::getpid()},
|
||||
unsafe {COUNT.fetch_add(1, Relaxed)});
|
||||
let string = format!("rust-test-unix-path-{}-{}-{}",
|
||||
base_port(),
|
||||
unsafe {libc::getpid()},
|
||||
unsafe {COUNT.fetch_add(1, Relaxed)});
|
||||
if cfg!(unix) {
|
||||
os::tmpdir().join(string)
|
||||
} else {
|
||||
Path::new(format_strbuf!("{}{}", r"\\.\pipe\", string))
|
||||
Path::new(format!("{}{}", r"\\.\pipe\", string))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,14 +229,6 @@ macro_rules! format(
|
||||
)
|
||||
)
|
||||
|
||||
/// Temporary transitionary thing.
|
||||
#[macro_export]
|
||||
macro_rules! format_strbuf(
|
||||
($($arg:tt)*) => (
|
||||
format_args!(::std::fmt::format_strbuf, $($arg)*)
|
||||
)
|
||||
)
|
||||
|
||||
/// Use the `format!` syntax to write data into a buffer of type `&mut Writer`.
|
||||
/// See `std::fmt` for more information.
|
||||
///
|
||||
|
@ -78,7 +78,7 @@ impl ToStrRadix for $T {
|
||||
/// Convert to a string in a given base.
|
||||
#[inline]
|
||||
fn to_str_radix(&self, radix: uint) -> String {
|
||||
format_strbuf!("{}", ::fmt::radix(*self, radix as u8))
|
||||
format!("{}", ::fmt::radix(*self, radix as u8))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ impl ToStrRadix for $T {
|
||||
/// Convert to a string in a given base.
|
||||
#[inline]
|
||||
fn to_str_radix(&self, radix: uint) -> String {
|
||||
format_strbuf!("{}", ::fmt::radix(*self, radix as u8))
|
||||
format!("{}", ::fmt::radix(*self, radix as u8))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -437,7 +437,7 @@ pub fn pipe() -> Pipe {
|
||||
|
||||
/// Returns the proper dll filename for the given basename of a file.
|
||||
pub fn dll_filename(base: &str) -> String {
|
||||
format_strbuf!("{}{}{}", consts::DLL_PREFIX, base, consts::DLL_SUFFIX)
|
||||
format!("{}{}{}", consts::DLL_PREFIX, base, consts::DLL_SUFFIX)
|
||||
}
|
||||
|
||||
/// Optionally returns the filesystem path of the current executable which is
|
||||
@ -1513,7 +1513,7 @@ mod tests {
|
||||
|
||||
fn make_rand_name() -> String {
|
||||
let mut rng = rand::task_rng();
|
||||
let n = format_strbuf!("TEST{}", rng.gen_ascii_str(10u).as_slice());
|
||||
let n = format!("TEST{}", rng.gen_ascii_str(10u).as_slice());
|
||||
assert!(getenv(n.as_slice()).is_none());
|
||||
n
|
||||
}
|
||||
|
@ -900,7 +900,7 @@ pub fn make_non_verbatim(path: &Path) -> Option<Path> {
|
||||
}
|
||||
Some(VerbatimUNCPrefix(_,_)) => {
|
||||
// \\?\UNC\server\share
|
||||
Path::new(format_strbuf!(r"\\{}", repr.slice_from(7)))
|
||||
Path::new(format!(r"\\{}", repr.slice_from(7)))
|
||||
}
|
||||
};
|
||||
if new_path.prefix.is_none() {
|
||||
|
@ -354,7 +354,7 @@ pub fn begin_unwind_fmt(msg: &fmt::Arguments, file: &'static str,
|
||||
// required with the current scheme, and (b) we don't handle
|
||||
// failure + OOM properly anyway (see comment in begin_unwind
|
||||
// below).
|
||||
begin_unwind_inner(box fmt::format_strbuf(msg), file, line)
|
||||
begin_unwind_inner(box fmt::format(msg), file, line)
|
||||
}
|
||||
|
||||
/// This is the entry point of unwinding for fail!() and assert!().
|
||||
|
@ -2123,7 +2123,7 @@ mod tests {
|
||||
assert_eq!(s.len(), 5);
|
||||
assert_eq!(s.as_slice(), "abcde");
|
||||
assert_eq!(s.to_str(), "abcde".to_string());
|
||||
assert_eq!(format_strbuf!("{}", s), "abcde".to_string());
|
||||
assert_eq!(format!("{}", s), "abcde".to_string());
|
||||
assert!(s.lt(&Owned("bcdef".to_string())));
|
||||
assert_eq!(Slice(""), Default::default());
|
||||
|
||||
@ -2131,7 +2131,7 @@ mod tests {
|
||||
assert_eq!(o.len(), 5);
|
||||
assert_eq!(o.as_slice(), "abcde");
|
||||
assert_eq!(o.to_str(), "abcde".to_string());
|
||||
assert_eq!(format_strbuf!("{}", o), "abcde".to_string());
|
||||
assert_eq!(format!("{}", o), "abcde".to_string());
|
||||
assert!(o.lt(&Slice("bcdef")));
|
||||
assert_eq!(Owned("".to_string()), Default::default());
|
||||
|
||||
|
@ -31,7 +31,7 @@ pub trait IntoStr {
|
||||
|
||||
impl<T: fmt::Show> ToStr for T {
|
||||
fn to_str(&self) -> String {
|
||||
format_strbuf!("{}", *self)
|
||||
format!("{}", *self)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -895,8 +895,8 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span,
|
||||
match parser.errors.shift() {
|
||||
Some(error) => {
|
||||
cx.ecx.span_err(efmt.span,
|
||||
format_strbuf!("invalid format string: {}",
|
||||
error).as_slice());
|
||||
format!("invalid format string: {}",
|
||||
error).as_slice());
|
||||
return DummyResult::raw_expr(sp);
|
||||
}
|
||||
None => {}
|
||||
|
@ -281,9 +281,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
|
||||
';' => (),
|
||||
|
||||
_ => {
|
||||
return Err(format_strbuf!("unrecognized format \
|
||||
option {}",
|
||||
cur))
|
||||
return Err(format!("unrecognized format option {}", cur))
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -549,8 +547,8 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,String> {
|
||||
s
|
||||
}
|
||||
_ => {
|
||||
return Err(format_strbuf!("non-string on stack with %{}",
|
||||
op.to_char()))
|
||||
return Err(format!("non-string on stack with %{}",
|
||||
op.to_char()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ pub fn parse(file: &mut io::Reader, longnames: bool)
|
||||
macro_rules! try( ($e:expr) => (
|
||||
match $e {
|
||||
Ok(e) => e,
|
||||
Err(e) => return Err(format_strbuf!("{}", e))
|
||||
Err(e) => return Err(format!("{}", e))
|
||||
}
|
||||
) )
|
||||
|
||||
@ -185,10 +185,8 @@ pub fn parse(file: &mut io::Reader, longnames: bool)
|
||||
// Check magic number
|
||||
let magic = try!(file.read_le_u16());
|
||||
if magic != 0x011A {
|
||||
return Err(format_strbuf!("invalid magic number: expected {:x} but \
|
||||
found {:x}",
|
||||
0x011A,
|
||||
magic as uint));
|
||||
return Err(format!("invalid magic number: expected {:x} but found {:x}",
|
||||
0x011A, magic as uint));
|
||||
}
|
||||
|
||||
let names_bytes = try!(file.read_le_i16()) as int;
|
||||
|
@ -81,11 +81,11 @@ pub fn open(term: &str) -> Result<File, String> {
|
||||
Some(x) => {
|
||||
match File::open(x) {
|
||||
Ok(file) => Ok(file),
|
||||
Err(e) => Err(format_strbuf!("error opening file: {}", e)),
|
||||
Err(e) => Err(format!("error opening file: {}", e)),
|
||||
}
|
||||
}
|
||||
None => {
|
||||
Err(format_strbuf!("could not find terminfo entry for {}", term))
|
||||
Err(format!("could not find terminfo entry for {}", term))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
|
||||
let s = matches.free.get(0).as_slice();
|
||||
match Regex::new(s) {
|
||||
Ok(re) => Some(re),
|
||||
Err(e) => return Some(Err(format_strbuf!("could not parse /{}/: {}", s, e)))
|
||||
Err(e) => return Some(Err(format!("could not parse /{}/: {}", s, e)))
|
||||
}
|
||||
} else {
|
||||
None
|
||||
@ -739,22 +739,20 @@ impl<T: Writer> ConsoleTestState<T> {
|
||||
pub fn fmt_metrics(mm: &MetricMap) -> String {
|
||||
let MetricMap(ref mm) = *mm;
|
||||
let v : Vec<String> = mm.iter()
|
||||
.map(|(k,v)| format_strbuf!("{}: {} (+/- {})",
|
||||
*k,
|
||||
v.value as f64,
|
||||
v.noise as f64))
|
||||
.map(|(k,v)| format!("{}: {} (+/- {})", *k,
|
||||
v.value as f64, v.noise as f64))
|
||||
.collect();
|
||||
v.connect(", ").to_string()
|
||||
}
|
||||
|
||||
pub fn fmt_bench_samples(bs: &BenchSamples) -> String {
|
||||
if bs.mb_s != 0 {
|
||||
format_strbuf!("{:>9} ns/iter (+/- {}) = {} MB/s",
|
||||
format!("{:>9} ns/iter (+/- {}) = {} MB/s",
|
||||
bs.ns_iter_summ.median as uint,
|
||||
(bs.ns_iter_summ.max - bs.ns_iter_summ.min) as uint,
|
||||
bs.mb_s)
|
||||
} else {
|
||||
format_strbuf!("{:>9} ns/iter (+/- {})",
|
||||
format!("{:>9} ns/iter (+/- {})",
|
||||
bs.ns_iter_summ.median as uint,
|
||||
(bs.ns_iter_summ.max - bs.ns_iter_summ.min) as uint)
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ impl Tm {
|
||||
let mut m = num::abs(self.tm_gmtoff) / 60_i32;
|
||||
let h = m / 60_i32;
|
||||
m -= h * 60_i32;
|
||||
format_strbuf!("{}{}{:02d}:{:02d}", s, sign, h as int, m as int)
|
||||
format!("{}{}{:02d}:{:02d}", s, sign, h as int, m as int)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -469,7 +469,7 @@ pub fn strptime(s: &str, format: &str) -> Result<Tm, String> {
|
||||
if c == range.ch {
|
||||
Ok(range.next)
|
||||
} else {
|
||||
Err(format_strbuf!("Expected {}, found {}",
|
||||
Err(format!("Expected {}, found {}",
|
||||
str::from_char(c),
|
||||
str::from_char(range.ch)))
|
||||
}
|
||||
@ -772,8 +772,7 @@ pub fn strptime(s: &str, format: &str) -> Result<Tm, String> {
|
||||
}
|
||||
'%' => parse_char(s, pos, '%'),
|
||||
ch => {
|
||||
Err(format_strbuf!("unknown formatting type: {}",
|
||||
str::from_char(ch)))
|
||||
Err(format!("unknown formatting type: {}", str::from_char(ch)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -889,16 +888,16 @@ pub fn strftime(format: &str, tm: &Tm) -> String {
|
||||
}
|
||||
|
||||
match ch {
|
||||
'G' => format_strbuf!("{}", year),
|
||||
'g' => format_strbuf!("{:02d}", (year % 100 + 100) % 100),
|
||||
'V' => format_strbuf!("{:02d}", days / 7 + 1),
|
||||
'G' => format!("{}", year),
|
||||
'g' => format!("{:02d}", (year % 100 + 100) % 100),
|
||||
'V' => format!("{:02d}", days / 7 + 1),
|
||||
_ => "".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_type(ch: char, tm: &Tm) -> String {
|
||||
let die = || {
|
||||
format_strbuf!("strftime: can't understand this format {} ", ch)
|
||||
format!("strftime: can't understand this format {} ", ch)
|
||||
};
|
||||
match ch {
|
||||
'A' => match tm.tm_wday as int {
|
||||
@ -951,9 +950,9 @@ pub fn strftime(format: &str, tm: &Tm) -> String {
|
||||
11 => "Dec".to_string(),
|
||||
_ => die()
|
||||
},
|
||||
'C' => format_strbuf!("{:02d}", (tm.tm_year as int + 1900) / 100),
|
||||
'C' => format!("{:02d}", (tm.tm_year as int + 1900) / 100),
|
||||
'c' => {
|
||||
format_strbuf!("{} {} {} {} {}",
|
||||
format!("{} {} {} {} {}",
|
||||
parse_type('a', tm),
|
||||
parse_type('b', tm),
|
||||
parse_type('e', tm),
|
||||
@ -961,89 +960,89 @@ pub fn strftime(format: &str, tm: &Tm) -> String {
|
||||
parse_type('Y', tm))
|
||||
}
|
||||
'D' | 'x' => {
|
||||
format_strbuf!("{}/{}/{}",
|
||||
format!("{}/{}/{}",
|
||||
parse_type('m', tm),
|
||||
parse_type('d', tm),
|
||||
parse_type('y', tm))
|
||||
}
|
||||
'd' => format_strbuf!("{:02d}", tm.tm_mday),
|
||||
'e' => format_strbuf!("{:2d}", tm.tm_mday),
|
||||
'f' => format_strbuf!("{:09d}", tm.tm_nsec),
|
||||
'd' => format!("{:02d}", tm.tm_mday),
|
||||
'e' => format!("{:2d}", tm.tm_mday),
|
||||
'f' => format!("{:09d}", tm.tm_nsec),
|
||||
'F' => {
|
||||
format_strbuf!("{}-{}-{}",
|
||||
format!("{}-{}-{}",
|
||||
parse_type('Y', tm),
|
||||
parse_type('m', tm),
|
||||
parse_type('d', tm))
|
||||
}
|
||||
'G' => iso_week('G', tm),
|
||||
'g' => iso_week('g', tm),
|
||||
'H' => format_strbuf!("{:02d}", tm.tm_hour),
|
||||
'H' => format!("{:02d}", tm.tm_hour),
|
||||
'I' => {
|
||||
let mut h = tm.tm_hour;
|
||||
if h == 0 { h = 12 }
|
||||
if h > 12 { h -= 12 }
|
||||
format_strbuf!("{:02d}", h)
|
||||
format!("{:02d}", h)
|
||||
}
|
||||
'j' => format_strbuf!("{:03d}", tm.tm_yday + 1),
|
||||
'k' => format_strbuf!("{:2d}", tm.tm_hour),
|
||||
'j' => format!("{:03d}", tm.tm_yday + 1),
|
||||
'k' => format!("{:2d}", tm.tm_hour),
|
||||
'l' => {
|
||||
let mut h = tm.tm_hour;
|
||||
if h == 0 { h = 12 }
|
||||
if h > 12 { h -= 12 }
|
||||
format_strbuf!("{:2d}", h)
|
||||
format!("{:2d}", h)
|
||||
}
|
||||
'M' => format_strbuf!("{:02d}", tm.tm_min),
|
||||
'm' => format_strbuf!("{:02d}", tm.tm_mon + 1),
|
||||
'M' => format!("{:02d}", tm.tm_min),
|
||||
'm' => format!("{:02d}", tm.tm_mon + 1),
|
||||
'n' => "\n".to_string(),
|
||||
'P' => if (tm.tm_hour as int) < 12 { "am".to_string() } else { "pm".to_string() },
|
||||
'p' => if (tm.tm_hour as int) < 12 { "AM".to_string() } else { "PM".to_string() },
|
||||
'R' => {
|
||||
format_strbuf!("{}:{}",
|
||||
format!("{}:{}",
|
||||
parse_type('H', tm),
|
||||
parse_type('M', tm))
|
||||
}
|
||||
'r' => {
|
||||
format_strbuf!("{}:{}:{} {}",
|
||||
format!("{}:{}:{} {}",
|
||||
parse_type('I', tm),
|
||||
parse_type('M', tm),
|
||||
parse_type('S', tm),
|
||||
parse_type('p', tm))
|
||||
}
|
||||
'S' => format_strbuf!("{:02d}", tm.tm_sec),
|
||||
's' => format_strbuf!("{}", tm.to_timespec().sec),
|
||||
'S' => format!("{:02d}", tm.tm_sec),
|
||||
's' => format!("{}", tm.to_timespec().sec),
|
||||
'T' | 'X' => {
|
||||
format_strbuf!("{}:{}:{}",
|
||||
format!("{}:{}:{}",
|
||||
parse_type('H', tm),
|
||||
parse_type('M', tm),
|
||||
parse_type('S', tm))
|
||||
}
|
||||
't' => "\t".to_string(),
|
||||
'U' => format_strbuf!("{:02d}", (tm.tm_yday - tm.tm_wday + 7) / 7),
|
||||
'U' => format!("{:02d}", (tm.tm_yday - tm.tm_wday + 7) / 7),
|
||||
'u' => {
|
||||
let i = tm.tm_wday as int;
|
||||
(if i == 0 { 7 } else { i }).to_str().to_string()
|
||||
}
|
||||
'V' => iso_week('V', tm),
|
||||
'v' => {
|
||||
format_strbuf!("{}-{}-{}",
|
||||
format!("{}-{}-{}",
|
||||
parse_type('e', tm),
|
||||
parse_type('b', tm),
|
||||
parse_type('Y', tm))
|
||||
}
|
||||
'W' => {
|
||||
format_strbuf!("{:02d}",
|
||||
format!("{:02d}",
|
||||
(tm.tm_yday - (tm.tm_wday - 1 + 7) % 7 + 7) / 7)
|
||||
}
|
||||
'w' => (tm.tm_wday as int).to_str().to_string(),
|
||||
'Y' => (tm.tm_year as int + 1900).to_str().to_string(),
|
||||
'y' => format_strbuf!("{:02d}", (tm.tm_year as int + 1900) % 100),
|
||||
'y' => format!("{:02d}", (tm.tm_year as int + 1900) % 100),
|
||||
'Z' => "".to_string(), // FIXME(pcwalton): Implement this.
|
||||
'z' => {
|
||||
let sign = if tm.tm_gmtoff > 0_i32 { '+' } else { '-' };
|
||||
let mut m = num::abs(tm.tm_gmtoff) / 60_i32;
|
||||
let h = m / 60_i32;
|
||||
m -= h * 60_i32;
|
||||
format_strbuf!("{}{:02d}{:02d}", sign, h, m)
|
||||
format!("{}{:02d}{:02d}", sign, h, m)
|
||||
}
|
||||
'+' => tm.rfc3339(),
|
||||
'%' => "%".to_string(),
|
||||
|
@ -346,8 +346,8 @@ impl Uuid {
|
||||
uf.data1 = to_be32(uf.data1);
|
||||
uf.data2 = to_be16(uf.data2);
|
||||
uf.data3 = to_be16(uf.data3);
|
||||
let s = format_strbuf!("{:08x}-{:04x}-{:04x}-{:02x}{:02x}-\
|
||||
{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}",
|
||||
let s = format!("{:08x}-{:04x}-{:04x}-{:02x}{:02x}-\
|
||||
{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}",
|
||||
uf.data1,
|
||||
uf.data2, uf.data3,
|
||||
uf.data4[0], uf.data4[1],
|
||||
@ -362,7 +362,7 @@ impl Uuid {
|
||||
///
|
||||
/// Example: `urn:uuid:F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4`
|
||||
pub fn to_urn_str(&self) -> String {
|
||||
format_strbuf!("urn:uuid:{}", self.to_hyphenated_str())
|
||||
format!("urn:uuid:{}", self.to_hyphenated_str())
|
||||
}
|
||||
|
||||
/// Parses a UUID from a string of hexadecimal digits with optional hyphens
|
||||
|
@ -74,8 +74,8 @@ fn main() {
|
||||
let b = bottom_up_tree(&arena, -i, depth);
|
||||
chk += item_check(a) + item_check(b);
|
||||
}
|
||||
format_strbuf!("{}\t trees of depth {}\t check: {}",
|
||||
iterations * 2, depth, chk)
|
||||
format!("{}\t trees of depth {}\t check: {}",
|
||||
iterations * 2, depth, chk)
|
||||
})
|
||||
}).collect::<Vec<Future<String>>>();
|
||||
|
||||
|
@ -134,9 +134,7 @@ fn creature(
|
||||
}
|
||||
}
|
||||
// log creatures met and evil clones of self
|
||||
let report = format_strbuf!("{}{}",
|
||||
creatures_met,
|
||||
Number(evil_clones_met));
|
||||
let report = format!("{}{}", creatures_met, Number(evil_clones_met));
|
||||
to_rendezvous_log.send(report);
|
||||
}
|
||||
|
||||
|
@ -129,11 +129,11 @@ fn make_sequence_processor(sz: uint,
|
||||
let buffer = match sz {
|
||||
1u => { sort_and_fmt(&freqs, total) }
|
||||
2u => { sort_and_fmt(&freqs, total) }
|
||||
3u => { format_strbuf!("{}\t{}", find(&freqs, "GGT".to_string()), "GGT") }
|
||||
4u => { format_strbuf!("{}\t{}", find(&freqs, "GGTA".to_string()), "GGTA") }
|
||||
6u => { format_strbuf!("{}\t{}", find(&freqs, "GGTATT".to_string()), "GGTATT") }
|
||||
12u => { format_strbuf!("{}\t{}", find(&freqs, "GGTATTTTAATT".to_string()), "GGTATTTTAATT") }
|
||||
18u => { format_strbuf!("{}\t{}", find(&freqs, "GGTATTTTAATTTATAGT".to_string()),
|
||||
3u => { format!("{}\t{}", find(&freqs, "GGT".to_string()), "GGT") }
|
||||
4u => { format!("{}\t{}", find(&freqs, "GGTA".to_string()), "GGTA") }
|
||||
6u => { format!("{}\t{}", find(&freqs, "GGTATT".to_string()), "GGTATT") }
|
||||
12u => { format!("{}\t{}", find(&freqs, "GGTATTTTAATT".to_string()), "GGTATTTTAATT") }
|
||||
18u => { format!("{}\t{}", find(&freqs, "GGTATTTTAATTTATAGT".to_string()),
|
||||
"GGTATTTTAATTTATAGT") }
|
||||
_ => { "".to_string() }
|
||||
};
|
||||
|
@ -11,8 +11,8 @@
|
||||
// Regression test for #13428
|
||||
|
||||
fn foo() -> String { //~ ERROR not all control paths return a value
|
||||
format_strbuf!("Hello {}",
|
||||
"world")
|
||||
format!("Hello {}",
|
||||
"world")
|
||||
// Put the trailing semicolon on its own line to test that the
|
||||
// note message gets the offending semicolon exactly
|
||||
; //~ NOTE consider removing this semicolon
|
||||
|
@ -15,5 +15,5 @@
|
||||
fn main() {
|
||||
let mut a = 1;
|
||||
if 1 == 1 { a = 2; }
|
||||
fail!(format_strbuf!("woooo{}", "o"));
|
||||
fail!(format!("woooo{}", "o"));
|
||||
}
|
||||
|
@ -20,10 +20,10 @@ fn main() {
|
||||
macerate((*tasties).clone());
|
||||
});
|
||||
result(carrots, |food| {
|
||||
let mush = format_strbuf!("{}{}", food, cheese);
|
||||
let mush = format!("{}{}", food, cheese);
|
||||
let cheese = cheese.clone();
|
||||
let f: || = || {
|
||||
let _chew = format_strbuf!("{}{}", mush, cheese);
|
||||
let _chew = format!("{}{}", mush, cheese);
|
||||
fail!("so yummy")
|
||||
};
|
||||
f();
|
||||
|
@ -16,13 +16,13 @@ trait Foo {
|
||||
|
||||
impl<T:Foo> Foo for @T {
|
||||
fn foo(&self) -> String {
|
||||
format_strbuf!("@{}", (**self).foo())
|
||||
format!("@{}", (**self).foo())
|
||||
}
|
||||
}
|
||||
|
||||
impl Foo for uint {
|
||||
fn foo(&self) -> String {
|
||||
format_strbuf!("{}", *self)
|
||||
format!("{}", *self)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,15 +19,15 @@ fn hello<S:Speak>(s:&S) -> String{
|
||||
|
||||
impl Speak for int {
|
||||
fn say(&self, s:&str) -> String {
|
||||
format_strbuf!("{}: {}", s, *self)
|
||||
format!("{}: {}", s, *self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Speak> Speak for Option<T> {
|
||||
fn say(&self, s:&str) -> String {
|
||||
match *self {
|
||||
None => format_strbuf!("{} - none", s),
|
||||
Some(ref x) => { format_strbuf!("something!{}", x.say(s)) }
|
||||
None => format!("{} - none", s),
|
||||
Some(ref x) => { format!("something!{}", x.say(s)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,15 +50,15 @@ pub fn main() {
|
||||
|
||||
let greeting = "Hello ".to_string();
|
||||
call_it(proc(s) {
|
||||
format_strbuf!("{}{}", greeting, s)
|
||||
format!("{}{}", greeting, s)
|
||||
});
|
||||
|
||||
let greeting = "Goodbye ".to_string();
|
||||
call_it(proc(s) format_strbuf!("{}{}", greeting, s));
|
||||
call_it(proc(s) format!("{}{}", greeting, s));
|
||||
|
||||
let greeting = "How's life, ".to_string();
|
||||
call_it(proc(s: String) -> String {
|
||||
format_strbuf!("{}{}", greeting, s)
|
||||
format!("{}{}", greeting, s)
|
||||
});
|
||||
|
||||
// Closures
|
||||
|
@ -45,7 +45,7 @@ fn add_interface(_store: int, managed_ip: String, data: json::Json) -> (String,
|
||||
let name = lookup((*interface).clone(),
|
||||
"ifDescr".to_string(),
|
||||
"".to_string());
|
||||
let label = format_strbuf!("{}-{}", managed_ip, name);
|
||||
let label = format!("{}-{}", managed_ip, name);
|
||||
|
||||
(label, bool_value(false))
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
extern crate debug;
|
||||
|
||||
fn assert_repr_eq<T>(obj : T, expected : String) {
|
||||
assert_eq!(expected, format_strbuf!("{:?}", obj));
|
||||
assert_eq!(expected, format!("{:?}", obj));
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
@ -17,19 +17,19 @@ enum foo {
|
||||
}
|
||||
|
||||
fn check_log<T>(exp: String, v: T) {
|
||||
assert_eq!(exp, format_strbuf!("{:?}", v));
|
||||
assert_eq!(exp, format!("{:?}", v));
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let mut x = Some(a(22u));
|
||||
let exp = "Some(a(22u))".to_string();
|
||||
let act = format_strbuf!("{:?}", x);
|
||||
let act = format!("{:?}", x);
|
||||
assert_eq!(act, exp);
|
||||
check_log(exp, x);
|
||||
|
||||
x = None;
|
||||
let exp = "None".to_string();
|
||||
let act = format_strbuf!("{:?}", x);
|
||||
let act = format!("{:?}", x);
|
||||
assert_eq!(act, exp);
|
||||
check_log(exp, x);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ enum bar {
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!("a(22u)".to_string(), format_strbuf!("{:?}", a(22u)));
|
||||
assert_eq!("c".to_string(), format_strbuf!("{:?}", c));
|
||||
assert_eq!("d".to_string(), format_strbuf!("{:?}", d));
|
||||
assert_eq!("a(22u)".to_string(), format!("{:?}", a(22u)));
|
||||
assert_eq!("c".to_string(), format!("{:?}", c));
|
||||
assert_eq!("d".to_string(), format!("{:?}", d));
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ fn f2(ref_string: &str) -> String {
|
||||
match ref_string {
|
||||
"a" => "found a".to_string(),
|
||||
"b" => "found b".to_string(),
|
||||
s => format_strbuf!("not found ({})", s)
|
||||
s => format!("not found ({})", s)
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ fn g2(ref_1: &str, ref_2: &str) -> String {
|
||||
match (ref_1, ref_2) {
|
||||
("a", "b") => "found a,b".to_string(),
|
||||
("b", "c") => "found b,c".to_string(),
|
||||
(s1, s2) => format_strbuf!("not found ({}, {})", s1, s2)
|
||||
(s1, s2) => format!("not found ({}, {})", s1, s2)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,8 +45,8 @@ pub fn main() {
|
||||
assert_eq!(transform(Some(10)), Some("11".to_string()));
|
||||
assert_eq!(transform(None), None);
|
||||
assert!((vec!("hi".to_string()))
|
||||
.bind(|x| vec!(x.clone(), format_strbuf!("{}!", x)) )
|
||||
.bind(|x| vec!(x.clone(), format_strbuf!("{}?", x)) ) ==
|
||||
.bind(|x| vec!(x.clone(), format!("{}!", x)) )
|
||||
.bind(|x| vec!(x.clone(), format!("{}?", x)) ) ==
|
||||
vec!("hi".to_string(),
|
||||
"hi?".to_string(),
|
||||
"hi!".to_string(),
|
||||
|
@ -36,8 +36,7 @@ fn main() {
|
||||
let blah = "\u03c0\u042f\u97f3\u00e6\u221e";
|
||||
|
||||
let child_name = "child";
|
||||
let child_dir = format_strbuf!("process-spawn-with-unicode-params-{}",
|
||||
blah);
|
||||
let child_dir = format!("process-spawn-with-unicode-params-{}", blah);
|
||||
|
||||
// parameters sent to child / expected to be received from parent
|
||||
let arg = blah;
|
||||
|
@ -61,7 +61,7 @@ pub fn main() {
|
||||
assert_eq!(map.find(&Owned("def".to_string())), Some(&d));
|
||||
|
||||
assert!(map.pop(&Slice("foo")).is_some());
|
||||
assert_eq!(map.move_iter().map(|(k, v)| format_strbuf!("{}{}", k, v))
|
||||
assert_eq!(map.move_iter().map(|(k, v)| format!("{}{}", k, v))
|
||||
.collect::<Vec<String>>()
|
||||
.concat(),
|
||||
"abc50bcd51cde52def53".to_string());
|
||||
|
@ -14,7 +14,7 @@
|
||||
pub fn main() {
|
||||
let a: String = "hello".to_string();
|
||||
let b: String = "world".to_string();
|
||||
let s: String = format_strbuf!("{}{}", a, b);
|
||||
let s: String = format!("{}{}", a, b);
|
||||
println!("{}", s.clone());
|
||||
assert_eq!(s.as_slice()[9], 'd' as u8);
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user