Remove unnecessary to_string calls

This commit removes superfluous to_string calls from various places
This commit is contained in:
Piotr Jawniak 2014-06-26 08:15:14 +02:00
parent 99519cc8e6
commit f8e06c4965
26 changed files with 62 additions and 106 deletions

View file

@ -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;

View file

@ -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")

View file

@ -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);

View file

@ -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()));
}

View file

@ -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 {

View file

@ -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() {

View file

@ -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))
}
}
}

View file

@ -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("+")
}
}