mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-10 05:53:10 +00:00
Remove unnecessary to_string calls
This commit removes superfluous to_string calls from various places
This commit is contained in:
parent
99519cc8e6
commit
f8e06c4965
@ -320,7 +320,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
|
||||
|
||||
let config = &mut config;
|
||||
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)
|
||||
let compiler_run_result = compile_test(config, props, testfile);
|
||||
@ -1035,10 +1035,7 @@ fn compose_and_run_compiler(
|
||||
make_compile_args(config,
|
||||
&aux_props,
|
||||
crate_type.append(
|
||||
extra_link_args.iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice()),
|
||||
extra_link_args.as_slice()),
|
||||
|a,b| {
|
||||
let f = make_lib_name(a, b, testfile);
|
||||
ThisDirectory(f.dir_path())
|
||||
|
@ -49,9 +49,7 @@
|
||||
//! }
|
||||
//!
|
||||
//! fn main() {
|
||||
//! let args: Vec<String> = os::args().iter()
|
||||
//! .map(|x| x.to_string())
|
||||
//! .collect();
|
||||
//! let args: Vec<String> = os::args();
|
||||
//!
|
||||
//! let program = args.get(0).clone();
|
||||
//!
|
||||
|
@ -659,7 +659,7 @@ pub fn sanitize(s: &str) -> String {
|
||||
if result.len() > 0u &&
|
||||
result.as_slice()[0] != '_' as u8 &&
|
||||
! char::is_XID_start(result.as_slice()[0] as char) {
|
||||
return format!("_{}", result.as_slice()).to_string();
|
||||
return format!("_{}", result.as_slice());
|
||||
}
|
||||
|
||||
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 target = match matches.opt_str("target") {
|
||||
Some(supplied_target) => supplied_target.to_string(),
|
||||
None => driver::host_triple().to_string(),
|
||||
};
|
||||
let target = matches.opt_str("target").unwrap_or(
|
||||
driver::host_triple().to_string());
|
||||
let opt_level = {
|
||||
if (debugging_opts & NO_OPT) != 0 {
|
||||
No
|
||||
@ -705,10 +703,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||
Path::new(s.as_slice())
|
||||
}).collect();
|
||||
|
||||
let cfg = parse_cfgspecs(matches.opt_strs("cfg")
|
||||
.move_iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect());
|
||||
let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
|
||||
let test = matches.opt_present("test");
|
||||
let write_dependency_info = (matches.opt_present("dep-info"),
|
||||
matches.opt_str("dep-info")
|
||||
|
@ -595,7 +595,7 @@ impl pprust::PpAnn for IdentifiedAnnotation {
|
||||
}
|
||||
pprust::NodeBlock(blk) => {
|
||||
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) => {
|
||||
try!(pp::space(&mut s.s));
|
||||
@ -604,7 +604,7 @@ impl pprust::PpAnn for IdentifiedAnnotation {
|
||||
}
|
||||
pprust::NodePat(pat) => {
|
||||
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 lcfg = LabelledCFG { ast_map: &ty_cx.map,
|
||||
cfg: &cfg,
|
||||
name: format!("block{}", block.id).to_string(), };
|
||||
name: format!("block{}", block.id), };
|
||||
debug!("cfg: {:?}", cfg);
|
||||
let r = dot::render(&lcfg, &mut out);
|
||||
return expand_err_details(r);
|
||||
|
@ -137,8 +137,6 @@ mod rustc {
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let args = std::os::args().iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>();
|
||||
let args = std::os::args();
|
||||
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 {
|
||||
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 {
|
||||
|
@ -441,11 +441,11 @@ impl<'a> PluginMetadataReader<'a> {
|
||||
};
|
||||
let macros = decoder::get_exported_macros(library.metadata.as_slice());
|
||||
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 {
|
||||
lib: library.dylib.clone(),
|
||||
macros: macros.move_iter().map(|x| x.to_string()).collect(),
|
||||
macros: macros,
|
||||
registrar_symbol: registrar,
|
||||
};
|
||||
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 {
|
||||
fn repr(&self, tcx: &ty::ctxt) -> String {
|
||||
(format!("Loan_{:?}({}, {:?}, {:?}-{:?}, {})",
|
||||
format!("Loan_{:?}({}, {:?}, {:?}-{:?}, {})",
|
||||
self.index,
|
||||
self.loan_path.repr(tcx),
|
||||
self.kind,
|
||||
self.gen_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 {
|
||||
match self {
|
||||
&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 }) => {
|
||||
let s = tcx.map.node_to_str(var_id);
|
||||
let s = format!("$({} captured by id={})", s, closure_expr_id);
|
||||
s.to_string()
|
||||
format!("$({} captured by id={})", s, closure_expr_id)
|
||||
}
|
||||
|
||||
&LpExtend(ref lp, _, LpDeref(_)) => {
|
||||
(format!("{}.*", lp.repr(tcx))).to_string()
|
||||
format!("{}.*", lp.repr(tcx))
|
||||
}
|
||||
|
||||
&LpExtend(ref lp, _, LpInterior(ref interior)) => {
|
||||
(format!("{}.{}",
|
||||
lp.repr(tcx),
|
||||
interior.repr(tcx))).to_string()
|
||||
format!("{}.{}", lp.repr(tcx), interior.repr(tcx))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -629,7 +629,7 @@ impl Repr for ty::ParamBounds {
|
||||
for t in self.trait_bounds.iter() {
|
||||
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
|
||||
let id = (s.as_slice().words().map(|s| {
|
||||
let id = s.as_slice().words().map(|s| {
|
||||
match s.to_ascii_opt() {
|
||||
Some(s) => s.to_lower().into_str(),
|
||||
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
|
||||
// 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 {
|
||||
Some(ref mut builder) => {
|
||||
builder.push(level as u32, s.to_string(), id.clone())
|
||||
builder.push(level as u32, s.clone(), id.clone())
|
||||
}
|
||||
None => {""}
|
||||
};
|
||||
|
@ -370,8 +370,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> io::IoResult<String>
|
||||
search_index.push(IndexItem {
|
||||
ty: shortty(item),
|
||||
name: item.name.clone().unwrap(),
|
||||
path: fqp.slice_to(fqp.len() - 1).connect("::")
|
||||
.to_string(),
|
||||
path: fqp.slice_to(fqp.len() - 1).connect("::"),
|
||||
desc: shorter(item.doc_value()).to_string(),
|
||||
parent: Some(did),
|
||||
});
|
||||
|
@ -85,10 +85,7 @@ local_data_key!(pub analysiskey: core::CrateAnalysis)
|
||||
type Output = (clean::Crate, Vec<plugins::PluginJson> );
|
||||
|
||||
pub fn main() {
|
||||
std::os::set_exit_status(main_args(std::os::args().iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice()));
|
||||
std::os::set_exit_status(main_args(std::os::args().as_slice()));
|
||||
}
|
||||
|
||||
pub fn opts() -> Vec<getopts::OptGroup> {
|
||||
@ -184,17 +181,10 @@ pub fn main_args(args: &[String]) -> int {
|
||||
|
||||
match (should_test, markdown_input) {
|
||||
(true, true) => {
|
||||
return markdown::test(input,
|
||||
libs,
|
||||
test_args.move_iter().collect())
|
||||
return markdown::test(input, libs, test_args)
|
||||
}
|
||||
(true, false) => {
|
||||
return test::run(input,
|
||||
cfgs.move_iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect(),
|
||||
libs,
|
||||
test_args)
|
||||
return test::run(input, cfgs, libs, test_args)
|
||||
}
|
||||
(false, true) => return markdown::render(input, output.unwrap_or(Path::new("doc")),
|
||||
&matches),
|
||||
@ -273,10 +263,7 @@ fn acquire_input(input: &str,
|
||||
fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output {
|
||||
let mut default_passes = !matches.opt_present("no-defaults");
|
||||
let mut passes = matches.opt_strs("passes");
|
||||
let mut plugins = matches.opt_strs("plugins")
|
||||
.move_iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>();
|
||||
let mut plugins = matches.opt_strs("plugins");
|
||||
|
||||
// First, parse the crate and extract all relevant information.
|
||||
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 cr = cr;
|
||||
core::run_core(libs.move_iter().map(|x| x.clone()).collect(),
|
||||
cfgs.move_iter().map(|x| x.to_string()).collect(),
|
||||
cfgs,
|
||||
&cr)
|
||||
}).map_err(|boxed_any|format!("{:?}", boxed_any)).unwrap();
|
||||
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) =
|
||||
match (load_external_files(matches.opt_strs("markdown-in-header")
|
||||
.move_iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice()),
|
||||
load_external_files(matches.opt_strs("markdown-before-content")
|
||||
.move_iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice()),
|
||||
load_external_files(matches.opt_strs("markdown-after-content")
|
||||
.move_iter()
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice())) {
|
||||
(Some(a), Some(b), Some(c)) => (a,b,c),
|
||||
_ => return 3
|
||||
|
@ -348,7 +348,7 @@ pub fn unindent(s: &str) -> String {
|
||||
line.slice_from(min_indent).to_string()
|
||||
}
|
||||
}).collect::<Vec<_>>().as_slice());
|
||||
unindented.connect("\n").to_string()
|
||||
unindented.connect("\n")
|
||||
} else {
|
||||
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",
|
||||
ItemMac(..) => "macro"
|
||||
};
|
||||
(format!("{} {} (id={})", item_str, path_str, id)).to_string()
|
||||
format!("{} {} (id={})", item_str, path_str, id)
|
||||
}
|
||||
Some(NodeForeignItem(item)) => {
|
||||
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)) => {
|
||||
(format!("method {} in {} (id={})",
|
||||
format!("method {} in {} (id={})",
|
||||
token::get_ident(m.ident),
|
||||
map.path_to_str(id), id)).to_string()
|
||||
map.path_to_str(id), id)
|
||||
}
|
||||
Some(NodeTraitMethod(ref tm)) => {
|
||||
let m = ast_util::trait_method_to_ty_method(&**tm);
|
||||
(format!("method {} in {} (id={})",
|
||||
format!("method {} in {} (id={})",
|
||||
token::get_ident(m.ident),
|
||||
map.path_to_str(id), id)).to_string()
|
||||
map.path_to_str(id), id)
|
||||
}
|
||||
Some(NodeVariant(ref variant)) => {
|
||||
(format!("variant {} in {} (id={})",
|
||||
format!("variant {} in {} (id={})",
|
||||
token::get_ident(variant.node.name),
|
||||
map.path_to_str(id), id)).to_string()
|
||||
map.path_to_str(id), id)
|
||||
}
|
||||
Some(NodeExpr(ref expr)) => {
|
||||
(format!("expr {} (id={})",
|
||||
pprust::expr_to_str(&**expr), id)).to_string()
|
||||
format!("expr {} (id={})", pprust::expr_to_str(&**expr), id)
|
||||
}
|
||||
Some(NodeStmt(ref stmt)) => {
|
||||
(format!("stmt {} (id={})",
|
||||
pprust::stmt_to_str(&**stmt), id)).to_string()
|
||||
format!("stmt {} (id={})", pprust::stmt_to_str(&**stmt), id)
|
||||
}
|
||||
Some(NodeArg(ref pat)) => {
|
||||
(format!("arg {} (id={})",
|
||||
pprust::pat_to_str(&**pat), id)).to_string()
|
||||
format!("arg {} (id={})", pprust::pat_to_str(&**pat), id)
|
||||
}
|
||||
Some(NodeLocal(ref pat)) => {
|
||||
(format!("local {} (id={})",
|
||||
pprust::pat_to_str(&**pat), id)).to_string()
|
||||
format!("local {} (id={})", pprust::pat_to_str(&**pat), id)
|
||||
}
|
||||
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)) => {
|
||||
(format!("block {} (id={})",
|
||||
pprust::block_to_str(&**block), id)).to_string()
|
||||
format!("block {} (id={})", pprust::block_to_str(&**block), id)
|
||||
}
|
||||
Some(NodeStructCtor(_)) => {
|
||||
(format!("struct_ctor {} (id={})",
|
||||
map.path_to_str(id), id)).to_string()
|
||||
format!("struct_ctor {} (id={})", map.path_to_str(id), id)
|
||||
}
|
||||
Some(NodeLifetime(ref l)) => {
|
||||
(format!("lifetime {} (id={})",
|
||||
pprust::lifetime_to_str(&**l), id)).to_string()
|
||||
format!("lifetime {} (id={})",
|
||||
pprust::lifetime_to_str(&**l), id)
|
||||
}
|
||||
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")
|
||||
idents.iter().map(|i| {
|
||||
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
|
||||
@ -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
|
||||
// are parsed as u64, so we wouldn't want to print an extra negative
|
||||
// sign.
|
||||
Some(n) => format!("{}{}", n as u64, s).to_string(),
|
||||
Some(n) => format!("{}{}", n as u64, s),
|
||||
None => s.to_string()
|
||||
}
|
||||
}
|
||||
@ -150,7 +150,7 @@ pub fn uint_ty_to_str(t: UintTy, val: Option<u64>) -> String {
|
||||
};
|
||||
|
||||
match val {
|
||||
Some(n) => format!("{}{}", n, s).to_string(),
|
||||
Some(n) => format!("{}{}", n, s),
|
||||
None => s.to_string()
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ impl CrateId {
|
||||
}
|
||||
|
||||
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 {
|
||||
|
@ -1015,7 +1015,7 @@ impl<'a> TraitDef<'a> {
|
||||
to_set.expn_info = Some(box(GC) codemap::ExpnInfo {
|
||||
call_site: to_set,
|
||||
callee: codemap::NameAndSpan {
|
||||
name: format!("deriving({})", trait_name).to_string(),
|
||||
name: format!("deriving({})", trait_name),
|
||||
format: codemap::MacroAttribute,
|
||||
span: Some(self.span)
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> String {
|
||||
let lines = vertical_trim(lines);
|
||||
let lines = horizontal_trim(lines);
|
||||
|
||||
return lines.connect("\n").to_string();
|
||||
return lines.connect("\n");
|
||||
}
|
||||
|
||||
fail!("not a doc-comment: {}", comment);
|
||||
|
@ -111,7 +111,7 @@ impl Token {
|
||||
|
||||
pub fn tok_str(t: Token) -> String {
|
||||
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(),
|
||||
Begin(_) => return "BEGIN".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 {
|
||||
match vis {
|
||||
ast::Public => format!("pub {}", s).to_string(),
|
||||
ast::Public => format!("pub {}", s),
|
||||
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 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");
|
||||
if !nocapture {
|
||||
@ -756,7 +756,7 @@ pub fn fmt_metrics(mm: &MetricMap) -> String {
|
||||
.map(|(k,v)| format!("{}: {} (+/- {})", *k,
|
||||
v.value as f64, v.noise as f64))
|
||||
.collect();
|
||||
v.connect(", ").to_string()
|
||||
v.connect(", ")
|
||||
}
|
||||
|
||||
pub fn fmt_bench_samples(bs: &BenchSamples) -> String {
|
||||
|
@ -24,7 +24,7 @@ use std::vec;
|
||||
use std::io::File;
|
||||
|
||||
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());
|
||||
|
||||
macro_rules! bench (
|
||||
|
@ -19,7 +19,7 @@ trait Barks {
|
||||
|
||||
impl Barks for Dog {
|
||||
fn bark(&self) -> String {
|
||||
return format!("woof! (I'm {})", self.name).to_string();
|
||||
return format!("woof! (I'm {})", self.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user