Auto merge of #52805 - ljedrz:format_str_literal, r=petrochenkov

Don't format!() string literals

Prefer `to_string()` to `format!()` take 2, this time targetting string literals. In some cases (`&format!("...")` -> `"..."`) also removes allocations. Occurences of `format!("")` are changed to `String::new()`.
This commit is contained in:
bors
2018-07-30 06:29:39 +00:00
42 changed files with 168 additions and 172 deletions

View File

@@ -261,14 +261,14 @@ pub(crate) fn each_linked_rlib(sess: &Session,
.or_else(|| fmts.get(&config::CrateTypeProcMacro));
let fmts = match fmts {
Some(f) => f,
None => return Err(format!("could not find formats for rlibs"))
None => return Err("could not find formats for rlibs".to_string())
};
for &(cnum, ref path) in crates {
match fmts.get(cnum.as_usize() - 1) {
Some(&Linkage::NotLinked) |
Some(&Linkage::IncludedFromDylib) => continue,
Some(_) => {}
None => return Err(format!("could not find formats for rlibs"))
None => return Err("could not find formats for rlibs".to_string())
}
let name = &info.crate_name[&cnum];
let path = match *path {