mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Avoid ref when using format! in compiler
Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse.
This commit is contained in:
parent
9fd6c695da
commit
cc1aded86c
8 changed files with 13 additions and 13 deletions
|
@ -643,7 +643,7 @@ fn main() {
|
|||
let deletions = diff
|
||||
.deletions
|
||||
.iter()
|
||||
.format_with("\n", |v, f| f(&format!("Line {}: {}", line_number(v), &fmt_syntax(v))));
|
||||
.format_with("\n", |v, f| f(&format!("Line {}: {}", line_number(v), fmt_syntax(v))));
|
||||
|
||||
let actual = format!(
|
||||
"insertions:\n\n{insertions}\n\nreplacements:\n\n{replacements}\n\ndeletions:\n\n{deletions}\n"
|
||||
|
|
|
@ -179,18 +179,18 @@ pub fn ty_alias(
|
|||
}
|
||||
|
||||
if let Some(list) = type_param_bounds {
|
||||
s.push_str(&format!(" : {}", &list));
|
||||
s.push_str(&format!(" : {list}"));
|
||||
}
|
||||
|
||||
if let Some(cl) = where_clause {
|
||||
s.push_str(&format!(" {}", &cl.to_string()));
|
||||
s.push_str(&format!(" {cl}"));
|
||||
}
|
||||
|
||||
if let Some(exp) = assignment {
|
||||
if let Some(cl) = exp.1 {
|
||||
s.push_str(&format!(" = {} {}", &exp.0.to_string(), &cl.to_string()));
|
||||
s.push_str(&format!(" = {} {cl}", exp.0));
|
||||
} else {
|
||||
s.push_str(&format!(" = {}", &exp.0.to_string()));
|
||||
s.push_str(&format!(" = {}", exp.0));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue