mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Auto merge of #17641 - nyurik:optimize-refs, r=Veykril
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. See https://github.com/rust-lang/rust-clippy/issues/10851
This commit is contained in:
commit
062822ce91
7 changed files with 12 additions and 12 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