Remove unnecessary to_string calls
This commit removes superfluous to_string calls from various places
This commit is contained in:
parent
99519cc8e6
commit
f8e06c4965
26 changed files with 62 additions and 106 deletions
|
@ -320,7 +320,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||||
|
|
||||||
let config = &mut config;
|
let config = &mut config;
|
||||||
let DebuggerCommands { commands, check_lines, .. } = parse_debugger_commands(testfile, "gdb");
|
let DebuggerCommands { commands, check_lines, .. } = parse_debugger_commands(testfile, "gdb");
|
||||||
let mut cmds = commands.connect("\n").to_string();
|
let mut cmds = commands.connect("\n");
|
||||||
|
|
||||||
// compile test file (it shoud have 'compile-flags:-g' in the header)
|
// compile test file (it shoud have 'compile-flags:-g' in the header)
|
||||||
let compiler_run_result = compile_test(config, props, testfile);
|
let compiler_run_result = compile_test(config, props, testfile);
|
||||||
|
@ -1035,10 +1035,7 @@ fn compose_and_run_compiler(
|
||||||
make_compile_args(config,
|
make_compile_args(config,
|
||||||
&aux_props,
|
&aux_props,
|
||||||
crate_type.append(
|
crate_type.append(
|
||||||
extra_link_args.iter()
|
extra_link_args.as_slice()),
|
||||||
.map(|x| x.to_string())
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.as_slice()),
|
|
||||||
|a,b| {
|
|a,b| {
|
||||||
let f = make_lib_name(a, b, testfile);
|
let f = make_lib_name(a, b, testfile);
|
||||||
ThisDirectory(f.dir_path())
|
ThisDirectory(f.dir_path())
|
||||||
|
|
|
@ -49,9 +49,7 @@
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! fn main() {
|
//! fn main() {
|
||||||
//! let args: Vec<String> = os::args().iter()
|
//! let args: Vec<String> = os::args();
|
||||||
//! .map(|x| x.to_string())
|
|
||||||
//! .collect();
|
|
||||||
//!
|
//!
|
||||||
//! let program = args.get(0).clone();
|
//! let program = args.get(0).clone();
|
||||||
//!
|
//!
|
||||||
|
|
|
@ -659,7 +659,7 @@ pub fn sanitize(s: &str) -> String {
|
||||||
if result.len() > 0u &&
|
if result.len() > 0u &&
|
||||||
result.as_slice()[0] != '_' as u8 &&
|
result.as_slice()[0] != '_' as u8 &&
|
||||||
! char::is_XID_start(result.as_slice()[0] as char) {
|
! char::is_XID_start(result.as_slice()[0] as char) {
|
||||||
return format!("_{}", result.as_slice()).to_string();
|
return format!("_{}", result.as_slice());
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -650,10 +650,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
}
|
}
|
||||||
|
|
||||||
let sysroot_opt = matches.opt_str("sysroot").map(|m| Path::new(m));
|
let sysroot_opt = matches.opt_str("sysroot").map(|m| Path::new(m));
|
||||||
let target = match matches.opt_str("target") {
|
let target = matches.opt_str("target").unwrap_or(
|
||||||
Some(supplied_target) => supplied_target.to_string(),
|
driver::host_triple().to_string());
|
||||||
None => driver::host_triple().to_string(),
|
|
||||||
};
|
|
||||||
let opt_level = {
|
let opt_level = {
|
||||||
if (debugging_opts & NO_OPT) != 0 {
|
if (debugging_opts & NO_OPT) != 0 {
|
||||||
No
|
No
|
||||||
|
@ -705,10 +703,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||||
Path::new(s.as_slice())
|
Path::new(s.as_slice())
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
let cfg = parse_cfgspecs(matches.opt_strs("cfg")
|
let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
|
||||||
.move_iter()
|
|
||||||
.map(|x| x.to_string())
|
|
||||||
.collect());
|
|
||||||
let test = matches.opt_present("test");
|
let test = matches.opt_present("test");
|
||||||
let write_dependency_info = (matches.opt_present("dep-info"),
|
let write_dependency_info = (matches.opt_present("dep-info"),
|
||||||
matches.opt_str("dep-info")
|
matches.opt_str("dep-info")
|
||||||
|
|
|
@ -595,7 +595,7 @@ impl pprust::PpAnn for IdentifiedAnnotation {
|
||||||
}
|
}
|
||||||
pprust::NodeBlock(blk) => {
|
pprust::NodeBlock(blk) => {
|
||||||
try!(pp::space(&mut s.s));
|
try!(pp::space(&mut s.s));
|
||||||
s.synth_comment((format!("block {}", blk.id)).to_string())
|
s.synth_comment(format!("block {}", blk.id))
|
||||||
}
|
}
|
||||||
pprust::NodeExpr(expr) => {
|
pprust::NodeExpr(expr) => {
|
||||||
try!(pp::space(&mut s.s));
|
try!(pp::space(&mut s.s));
|
||||||
|
@ -604,7 +604,7 @@ impl pprust::PpAnn for IdentifiedAnnotation {
|
||||||
}
|
}
|
||||||
pprust::NodePat(pat) => {
|
pprust::NodePat(pat) => {
|
||||||
try!(pp::space(&mut s.s));
|
try!(pp::space(&mut s.s));
|
||||||
s.synth_comment((format!("pat {}", pat.id)).to_string())
|
s.synth_comment(format!("pat {}", pat.id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -752,7 +752,7 @@ fn print_flowgraph<W:io::Writer>(analysis: CrateAnalysis,
|
||||||
let cfg = cfg::CFG::new(ty_cx, &*block);
|
let cfg = cfg::CFG::new(ty_cx, &*block);
|
||||||
let lcfg = LabelledCFG { ast_map: &ty_cx.map,
|
let lcfg = LabelledCFG { ast_map: &ty_cx.map,
|
||||||
cfg: &cfg,
|
cfg: &cfg,
|
||||||
name: format!("block{}", block.id).to_string(), };
|
name: format!("block{}", block.id), };
|
||||||
debug!("cfg: {:?}", cfg);
|
debug!("cfg: {:?}", cfg);
|
||||||
let r = dot::render(&lcfg, &mut out);
|
let r = dot::render(&lcfg, &mut out);
|
||||||
return expand_err_details(r);
|
return expand_err_details(r);
|
||||||
|
|
|
@ -137,8 +137,6 @@ mod rustc {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let args = std::os::args().iter()
|
let args = std::os::args();
|
||||||
.map(|x| x.to_string())
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
std::os::set_exit_status(driver::main_args(args.as_slice()));
|
std::os::set_exit_status(driver::main_args(args.as_slice()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1894,7 +1894,7 @@ impl TypeNames {
|
||||||
|
|
||||||
pub fn types_to_str(&self, tys: &[Type]) -> String {
|
pub fn types_to_str(&self, tys: &[Type]) -> String {
|
||||||
let strs: Vec<String> = tys.iter().map(|t| self.type_to_str(*t)).collect();
|
let strs: Vec<String> = tys.iter().map(|t| self.type_to_str(*t)).collect();
|
||||||
format!("[{}]", strs.connect(",").to_string())
|
format!("[{}]", strs.connect(","))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn val_to_str(&self, val: ValueRef) -> String {
|
pub fn val_to_str(&self, val: ValueRef) -> String {
|
||||||
|
|
|
@ -441,11 +441,11 @@ impl<'a> PluginMetadataReader<'a> {
|
||||||
};
|
};
|
||||||
let macros = decoder::get_exported_macros(library.metadata.as_slice());
|
let macros = decoder::get_exported_macros(library.metadata.as_slice());
|
||||||
let registrar = decoder::get_plugin_registrar_fn(library.metadata.as_slice()).map(|id| {
|
let registrar = decoder::get_plugin_registrar_fn(library.metadata.as_slice()).map(|id| {
|
||||||
decoder::get_symbol(library.metadata.as_slice(), id).to_string()
|
decoder::get_symbol(library.metadata.as_slice(), id)
|
||||||
});
|
});
|
||||||
let pc = PluginMetadata {
|
let pc = PluginMetadata {
|
||||||
lib: library.dylib.clone(),
|
lib: library.dylib.clone(),
|
||||||
macros: macros.move_iter().map(|x| x.to_string()).collect(),
|
macros: macros,
|
||||||
registrar_symbol: registrar,
|
registrar_symbol: registrar,
|
||||||
};
|
};
|
||||||
if should_link && existing_match(&self.env, &info.crate_id, None).is_none() {
|
if should_link && existing_match(&self.env, &info.crate_id, None).is_none() {
|
||||||
|
|
|
@ -801,13 +801,13 @@ impl DataFlowOperator for LoanDataFlowOperator {
|
||||||
|
|
||||||
impl Repr for Loan {
|
impl Repr for Loan {
|
||||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||||
(format!("Loan_{:?}({}, {:?}, {:?}-{:?}, {})",
|
format!("Loan_{:?}({}, {:?}, {:?}-{:?}, {})",
|
||||||
self.index,
|
self.index,
|
||||||
self.loan_path.repr(tcx),
|
self.loan_path.repr(tcx),
|
||||||
self.kind,
|
self.kind,
|
||||||
self.gen_scope,
|
self.gen_scope,
|
||||||
self.kill_scope,
|
self.kill_scope,
|
||||||
self.restricted_paths.repr(tcx))).to_string()
|
self.restricted_paths.repr(tcx))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -815,23 +815,20 @@ impl Repr for LoanPath {
|
||||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||||
match self {
|
match self {
|
||||||
&LpVar(id) => {
|
&LpVar(id) => {
|
||||||
(format!("$({})", tcx.map.node_to_str(id))).to_string()
|
format!("$({})", tcx.map.node_to_str(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
&LpUpvar(ty::UpvarId{ var_id, closure_expr_id }) => {
|
&LpUpvar(ty::UpvarId{ var_id, closure_expr_id }) => {
|
||||||
let s = tcx.map.node_to_str(var_id);
|
let s = tcx.map.node_to_str(var_id);
|
||||||
let s = format!("$({} captured by id={})", s, closure_expr_id);
|
format!("$({} captured by id={})", s, closure_expr_id)
|
||||||
s.to_string()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&LpExtend(ref lp, _, LpDeref(_)) => {
|
&LpExtend(ref lp, _, LpDeref(_)) => {
|
||||||
(format!("{}.*", lp.repr(tcx))).to_string()
|
format!("{}.*", lp.repr(tcx))
|
||||||
}
|
}
|
||||||
|
|
||||||
&LpExtend(ref lp, _, LpInterior(ref interior)) => {
|
&LpExtend(ref lp, _, LpInterior(ref interior)) => {
|
||||||
(format!("{}.{}",
|
format!("{}.{}", lp.repr(tcx), interior.repr(tcx))
|
||||||
lp.repr(tcx),
|
|
||||||
interior.repr(tcx))).to_string()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -629,7 +629,7 @@ impl Repr for ty::ParamBounds {
|
||||||
for t in self.trait_bounds.iter() {
|
for t in self.trait_bounds.iter() {
|
||||||
res.push(t.repr(tcx));
|
res.push(t.repr(tcx));
|
||||||
}
|
}
|
||||||
res.connect("+").to_string()
|
res.connect("+")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -228,12 +228,12 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Transform the contents of the header into a hyphenated string
|
// Transform the contents of the header into a hyphenated string
|
||||||
let id = (s.as_slice().words().map(|s| {
|
let id = s.as_slice().words().map(|s| {
|
||||||
match s.to_ascii_opt() {
|
match s.to_ascii_opt() {
|
||||||
Some(s) => s.to_lower().into_str(),
|
Some(s) => s.to_lower().into_str(),
|
||||||
None => s.to_string()
|
None => s.to_string()
|
||||||
}
|
}
|
||||||
}).collect::<Vec<String>>().connect("-")).to_string();
|
}).collect::<Vec<String>>().connect("-");
|
||||||
|
|
||||||
// This is a terrible hack working around how hoedown gives us rendered
|
// This is a terrible hack working around how hoedown gives us rendered
|
||||||
// html for text rather than the raw text.
|
// html for text rather than the raw text.
|
||||||
|
@ -252,7 +252,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
|
||||||
|
|
||||||
let sec = match opaque.toc_builder {
|
let sec = match opaque.toc_builder {
|
||||||
Some(ref mut builder) => {
|
Some(ref mut builder) => {
|
||||||
builder.push(level as u32, s.to_string(), id.clone())
|
builder.push(level as u32, s.clone(), id.clone())
|
||||||
}
|
}
|
||||||
None => {""}
|
None => {""}
|
||||||
};
|
};
|
||||||
|
|
|
@ -370,8 +370,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> io::IoResult<String>
|
||||||
search_index.push(IndexItem {
|
search_index.push(IndexItem {
|
||||||
ty: shortty(item),
|
ty: shortty(item),
|
||||||
name: item.name.clone().unwrap(),
|
name: item.name.clone().unwrap(),
|
||||||
path: fqp.slice_to(fqp.len() - 1).connect("::")
|
path: fqp.slice_to(fqp.len() - 1).connect("::"),
|
||||||
.to_string(),
|
|
||||||
desc: shorter(item.doc_value()).to_string(),
|
desc: shorter(item.doc_value()).to_string(),
|
||||||
parent: Some(did),
|
parent: Some(did),
|
||||||
});
|
});
|
||||||
|
|
|
@ -85,10 +85,7 @@ local_data_key!(pub analysiskey: core::CrateAnalysis)
|
||||||
type Output = (clean::Crate, Vec<plugins::PluginJson> );
|
type Output = (clean::Crate, Vec<plugins::PluginJson> );
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
std::os::set_exit_status(main_args(std::os::args().iter()
|
std::os::set_exit_status(main_args(std::os::args().as_slice()));
|
||||||
.map(|x| x.to_string())
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.as_slice()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn opts() -> Vec<getopts::OptGroup> {
|
pub fn opts() -> Vec<getopts::OptGroup> {
|
||||||
|
@ -184,17 +181,10 @@ pub fn main_args(args: &[String]) -> int {
|
||||||
|
|
||||||
match (should_test, markdown_input) {
|
match (should_test, markdown_input) {
|
||||||
(true, true) => {
|
(true, true) => {
|
||||||
return markdown::test(input,
|
return markdown::test(input, libs, test_args)
|
||||||
libs,
|
|
||||||
test_args.move_iter().collect())
|
|
||||||
}
|
}
|
||||||
(true, false) => {
|
(true, false) => {
|
||||||
return test::run(input,
|
return test::run(input, cfgs, libs, test_args)
|
||||||
cfgs.move_iter()
|
|
||||||
.map(|x| x.to_string())
|
|
||||||
.collect(),
|
|
||||||
libs,
|
|
||||||
test_args)
|
|
||||||
}
|
}
|
||||||
(false, true) => return markdown::render(input, output.unwrap_or(Path::new("doc")),
|
(false, true) => return markdown::render(input, output.unwrap_or(Path::new("doc")),
|
||||||
&matches),
|
&matches),
|
||||||
|
@ -273,10 +263,7 @@ fn acquire_input(input: &str,
|
||||||
fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
|
fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
|
||||||
let mut default_passes = !matches.opt_present("no-defaults");
|
let mut default_passes = !matches.opt_present("no-defaults");
|
||||||
let mut passes = matches.opt_strs("passes");
|
let mut passes = matches.opt_strs("passes");
|
||||||
let mut plugins = matches.opt_strs("plugins")
|
let mut plugins = matches.opt_strs("plugins");
|
||||||
.move_iter()
|
|
||||||
.map(|x| x.to_string())
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
// First, parse the crate and extract all relevant information.
|
// First, parse the crate and extract all relevant information.
|
||||||
let libs: Vec<Path> = matches.opt_strs("L")
|
let libs: Vec<Path> = matches.opt_strs("L")
|
||||||
|
@ -289,7 +276,7 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
|
||||||
let (krate, analysis) = std::task::try(proc() {
|
let (krate, analysis) = std::task::try(proc() {
|
||||||
let cr = cr;
|
let cr = cr;
|
||||||
core::run_core(libs.move_iter().map(|x| x.clone()).collect(),
|
core::run_core(libs.move_iter().map(|x| x.clone()).collect(),
|
||||||
cfgs.move_iter().map(|x| x.to_string()).collect(),
|
cfgs,
|
||||||
&cr)
|
&cr)
|
||||||
}).map_err(|boxed_any|format!("{:?}", boxed_any)).unwrap();
|
}).map_err(|boxed_any|format!("{:?}", boxed_any)).unwrap();
|
||||||
info!("finished with rustc");
|
info!("finished with rustc");
|
||||||
|
|
|
@ -93,19 +93,10 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches) -> int
|
||||||
|
|
||||||
let (in_header, before_content, after_content) =
|
let (in_header, before_content, after_content) =
|
||||||
match (load_external_files(matches.opt_strs("markdown-in-header")
|
match (load_external_files(matches.opt_strs("markdown-in-header")
|
||||||
.move_iter()
|
|
||||||
.map(|x| x.to_string())
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.as_slice()),
|
.as_slice()),
|
||||||
load_external_files(matches.opt_strs("markdown-before-content")
|
load_external_files(matches.opt_strs("markdown-before-content")
|
||||||
.move_iter()
|
|
||||||
.map(|x| x.to_string())
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.as_slice()),
|
.as_slice()),
|
||||||
load_external_files(matches.opt_strs("markdown-after-content")
|
load_external_files(matches.opt_strs("markdown-after-content")
|
||||||
.move_iter()
|
|
||||||
.map(|x| x.to_string())
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.as_slice())) {
|
.as_slice())) {
|
||||||
(Some(a), Some(b), Some(c)) => (a,b,c),
|
(Some(a), Some(b), Some(c)) => (a,b,c),
|
||||||
_ => return 3
|
_ => return 3
|
||||||
|
|
|
@ -348,7 +348,7 @@ pub fn unindent(s: &str) -> String {
|
||||||
line.slice_from(min_indent).to_string()
|
line.slice_from(min_indent).to_string()
|
||||||
}
|
}
|
||||||
}).collect::<Vec<_>>().as_slice());
|
}).collect::<Vec<_>>().as_slice());
|
||||||
unindented.connect("\n").to_string()
|
unindented.connect("\n")
|
||||||
} else {
|
} else {
|
||||||
s.to_string()
|
s.to_string()
|
||||||
}
|
}
|
||||||
|
|
|
@ -588,7 +588,7 @@ impl GenericPath for Path {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Path::new(comps.connect("\\").into_string()))
|
Some(Path::new(comps.connect("\\")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -680,61 +680,55 @@ fn node_id_to_str(map: &Map, id: NodeId) -> String {
|
||||||
ItemImpl(..) => "impl",
|
ItemImpl(..) => "impl",
|
||||||
ItemMac(..) => "macro"
|
ItemMac(..) => "macro"
|
||||||
};
|
};
|
||||||
(format!("{} {} (id={})", item_str, path_str, id)).to_string()
|
format!("{} {} (id={})", item_str, path_str, id)
|
||||||
}
|
}
|
||||||
Some(NodeForeignItem(item)) => {
|
Some(NodeForeignItem(item)) => {
|
||||||
let path_str = map.path_to_str_with_ident(id, item.ident);
|
let path_str = map.path_to_str_with_ident(id, item.ident);
|
||||||
(format!("foreign item {} (id={})", path_str, id)).to_string()
|
format!("foreign item {} (id={})", path_str, id)
|
||||||
}
|
}
|
||||||
Some(NodeMethod(m)) => {
|
Some(NodeMethod(m)) => {
|
||||||
(format!("method {} in {} (id={})",
|
format!("method {} in {} (id={})",
|
||||||
token::get_ident(m.ident),
|
token::get_ident(m.ident),
|
||||||
map.path_to_str(id), id)).to_string()
|
map.path_to_str(id), id)
|
||||||
}
|
}
|
||||||
Some(NodeTraitMethod(ref tm)) => {
|
Some(NodeTraitMethod(ref tm)) => {
|
||||||
let m = ast_util::trait_method_to_ty_method(&**tm);
|
let m = ast_util::trait_method_to_ty_method(&**tm);
|
||||||
(format!("method {} in {} (id={})",
|
format!("method {} in {} (id={})",
|
||||||
token::get_ident(m.ident),
|
token::get_ident(m.ident),
|
||||||
map.path_to_str(id), id)).to_string()
|
map.path_to_str(id), id)
|
||||||
}
|
}
|
||||||
Some(NodeVariant(ref variant)) => {
|
Some(NodeVariant(ref variant)) => {
|
||||||
(format!("variant {} in {} (id={})",
|
format!("variant {} in {} (id={})",
|
||||||
token::get_ident(variant.node.name),
|
token::get_ident(variant.node.name),
|
||||||
map.path_to_str(id), id)).to_string()
|
map.path_to_str(id), id)
|
||||||
}
|
}
|
||||||
Some(NodeExpr(ref expr)) => {
|
Some(NodeExpr(ref expr)) => {
|
||||||
(format!("expr {} (id={})",
|
format!("expr {} (id={})", pprust::expr_to_str(&**expr), id)
|
||||||
pprust::expr_to_str(&**expr), id)).to_string()
|
|
||||||
}
|
}
|
||||||
Some(NodeStmt(ref stmt)) => {
|
Some(NodeStmt(ref stmt)) => {
|
||||||
(format!("stmt {} (id={})",
|
format!("stmt {} (id={})", pprust::stmt_to_str(&**stmt), id)
|
||||||
pprust::stmt_to_str(&**stmt), id)).to_string()
|
|
||||||
}
|
}
|
||||||
Some(NodeArg(ref pat)) => {
|
Some(NodeArg(ref pat)) => {
|
||||||
(format!("arg {} (id={})",
|
format!("arg {} (id={})", pprust::pat_to_str(&**pat), id)
|
||||||
pprust::pat_to_str(&**pat), id)).to_string()
|
|
||||||
}
|
}
|
||||||
Some(NodeLocal(ref pat)) => {
|
Some(NodeLocal(ref pat)) => {
|
||||||
(format!("local {} (id={})",
|
format!("local {} (id={})", pprust::pat_to_str(&**pat), id)
|
||||||
pprust::pat_to_str(&**pat), id)).to_string()
|
|
||||||
}
|
}
|
||||||
Some(NodePat(ref pat)) => {
|
Some(NodePat(ref pat)) => {
|
||||||
(format!("pat {} (id={})", pprust::pat_to_str(&**pat), id)).to_string()
|
format!("pat {} (id={})", pprust::pat_to_str(&**pat), id)
|
||||||
}
|
}
|
||||||
Some(NodeBlock(ref block)) => {
|
Some(NodeBlock(ref block)) => {
|
||||||
(format!("block {} (id={})",
|
format!("block {} (id={})", pprust::block_to_str(&**block), id)
|
||||||
pprust::block_to_str(&**block), id)).to_string()
|
|
||||||
}
|
}
|
||||||
Some(NodeStructCtor(_)) => {
|
Some(NodeStructCtor(_)) => {
|
||||||
(format!("struct_ctor {} (id={})",
|
format!("struct_ctor {} (id={})", map.path_to_str(id), id)
|
||||||
map.path_to_str(id), id)).to_string()
|
|
||||||
}
|
}
|
||||||
Some(NodeLifetime(ref l)) => {
|
Some(NodeLifetime(ref l)) => {
|
||||||
(format!("lifetime {} (id={})",
|
format!("lifetime {} (id={})",
|
||||||
pprust::lifetime_to_str(&**l), id)).to_string()
|
pprust::lifetime_to_str(&**l), id)
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
(format!("unknown node (id={})", id)).to_string()
|
format!("unknown node (id={})", id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub fn path_name_i(idents: &[Ident]) -> String {
|
||||||
// FIXME: Bad copies (#2543 -- same for everything else that says "bad")
|
// FIXME: Bad copies (#2543 -- same for everything else that says "bad")
|
||||||
idents.iter().map(|i| {
|
idents.iter().map(|i| {
|
||||||
token::get_ident(*i).get().to_string()
|
token::get_ident(*i).get().to_string()
|
||||||
}).collect::<Vec<String>>().connect("::").to_string()
|
}).collect::<Vec<String>>().connect("::")
|
||||||
}
|
}
|
||||||
|
|
||||||
// totally scary function: ignores all but the last element, should have
|
// totally scary function: ignores all but the last element, should have
|
||||||
|
@ -123,7 +123,7 @@ pub fn int_ty_to_str(t: IntTy, val: Option<i64>) -> String {
|
||||||
// cast to a u64 so we can correctly print INT64_MIN. All integral types
|
// cast to a u64 so we can correctly print INT64_MIN. All integral types
|
||||||
// are parsed as u64, so we wouldn't want to print an extra negative
|
// are parsed as u64, so we wouldn't want to print an extra negative
|
||||||
// sign.
|
// sign.
|
||||||
Some(n) => format!("{}{}", n as u64, s).to_string(),
|
Some(n) => format!("{}{}", n as u64, s),
|
||||||
None => s.to_string()
|
None => s.to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ pub fn uint_ty_to_str(t: UintTy, val: Option<u64>) -> String {
|
||||||
};
|
};
|
||||||
|
|
||||||
match val {
|
match val {
|
||||||
Some(n) => format!("{}{}", n, s).to_string(),
|
Some(n) => format!("{}{}", n, s),
|
||||||
None => s.to_string()
|
None => s.to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ impl CrateId {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn short_name_with_version(&self) -> String {
|
pub fn short_name_with_version(&self) -> String {
|
||||||
(format!("{}-{}", self.name, self.version_or_default())).to_string()
|
format!("{}-{}", self.name, self.version_or_default())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn matches(&self, other: &CrateId) -> bool {
|
pub fn matches(&self, other: &CrateId) -> bool {
|
||||||
|
|
|
@ -1015,7 +1015,7 @@ impl<'a> TraitDef<'a> {
|
||||||
to_set.expn_info = Some(box(GC) codemap::ExpnInfo {
|
to_set.expn_info = Some(box(GC) codemap::ExpnInfo {
|
||||||
call_site: to_set,
|
call_site: to_set,
|
||||||
callee: codemap::NameAndSpan {
|
callee: codemap::NameAndSpan {
|
||||||
name: format!("deriving({})", trait_name).to_string(),
|
name: format!("deriving({})", trait_name),
|
||||||
format: codemap::MacroAttribute,
|
format: codemap::MacroAttribute,
|
||||||
span: Some(self.span)
|
span: Some(self.span)
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> String {
|
||||||
let lines = vertical_trim(lines);
|
let lines = vertical_trim(lines);
|
||||||
let lines = horizontal_trim(lines);
|
let lines = horizontal_trim(lines);
|
||||||
|
|
||||||
return lines.connect("\n").to_string();
|
return lines.connect("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
fail!("not a doc-comment: {}", comment);
|
fail!("not a doc-comment: {}", comment);
|
||||||
|
|
|
@ -111,7 +111,7 @@ impl Token {
|
||||||
|
|
||||||
pub fn tok_str(t: Token) -> String {
|
pub fn tok_str(t: Token) -> String {
|
||||||
match t {
|
match t {
|
||||||
String(s, len) => return format!("STR({},{})", s, len).to_string(),
|
String(s, len) => return format!("STR({},{})", s, len),
|
||||||
Break(_) => return "BREAK".to_string(),
|
Break(_) => return "BREAK".to_string(),
|
||||||
Begin(_) => return "BEGIN".to_string(),
|
Begin(_) => return "BEGIN".to_string(),
|
||||||
End => return "END".to_string(),
|
End => return "END".to_string(),
|
||||||
|
|
|
@ -243,7 +243,7 @@ pub fn arg_to_str(arg: &ast::Arg) -> String {
|
||||||
|
|
||||||
pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> String {
|
pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> String {
|
||||||
match vis {
|
match vis {
|
||||||
ast::Public => format!("pub {}", s).to_string(),
|
ast::Public => format!("pub {}", s),
|
||||||
ast::Inherited => s.to_string()
|
ast::Inherited => s.to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,7 +403,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
|
||||||
let save_metrics = save_metrics.map(|s| Path::new(s));
|
let save_metrics = save_metrics.map(|s| Path::new(s));
|
||||||
|
|
||||||
let test_shard = matches.opt_str("test-shard");
|
let test_shard = matches.opt_str("test-shard");
|
||||||
let test_shard = opt_shard(test_shard.map(|x| x.to_string()));
|
let test_shard = opt_shard(test_shard);
|
||||||
|
|
||||||
let mut nocapture = matches.opt_present("nocapture");
|
let mut nocapture = matches.opt_present("nocapture");
|
||||||
if !nocapture {
|
if !nocapture {
|
||||||
|
@ -756,7 +756,7 @@ pub fn fmt_metrics(mm: &MetricMap) -> String {
|
||||||
.map(|(k,v)| format!("{}: {} (+/- {})", *k,
|
.map(|(k,v)| format!("{}: {} (+/- {})", *k,
|
||||||
v.value as f64, v.noise as f64))
|
v.value as f64, v.noise as f64))
|
||||||
.collect();
|
.collect();
|
||||||
v.connect(", ").to_string()
|
v.connect(", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fmt_bench_samples(bs: &BenchSamples) -> String {
|
pub fn fmt_bench_samples(bs: &BenchSamples) -> String {
|
||||||
|
|
|
@ -24,7 +24,7 @@ use std::vec;
|
||||||
use std::io::File;
|
use std::io::File;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let argv = os::args().move_iter().map(|x| x.to_string()).collect::<Vec<String>>();
|
let argv = os::args();
|
||||||
let _tests = argv.slice(1, argv.len());
|
let _tests = argv.slice(1, argv.len());
|
||||||
|
|
||||||
macro_rules! bench (
|
macro_rules! bench (
|
||||||
|
|
|
@ -19,7 +19,7 @@ trait Barks {
|
||||||
|
|
||||||
impl Barks for Dog {
|
impl Barks for Dog {
|
||||||
fn bark(&self) -> String {
|
fn bark(&self) -> String {
|
||||||
return format!("woof! (I'm {})", self.name).to_string();
|
return format!("woof! (I'm {})", self.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue