1
Fork 0

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:
Yuri Astrakhan 2024-07-19 11:51:21 -04:00
parent 0cd01aac6a
commit aef0e346de
23 changed files with 61 additions and 65 deletions

View file

@ -694,7 +694,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
.collect::<Vec<_>>();
let msg = format!("unresolved import{} {}", pluralize!(paths.len()), paths.join(", "),);
let mut diag = struct_span_code_err!(self.dcx(), span, E0432, "{}", &msg);
let mut diag = struct_span_code_err!(self.dcx(), span, E0432, "{msg}");
if let Some((_, UnresolvedImportError { note: Some(note), .. })) = errors.iter().last() {
diag.note(note.clone());