diff options
| author | Yuri Astrakhan <YuriAstrakhan@gmail.com> | 2024-07-19 11:51:21 -0400 |
|---|---|---|
| committer | Yuri Astrakhan <YuriAstrakhan@gmail.com> | 2024-07-19 14:52:07 -0400 |
| commit | aef0e346de744faeaa522b9c08562bb3e1814adc (patch) | |
| tree | 1d670ae42ce9ba8f4160dae59cc5ad09ace97d86 /compiler/rustc_resolve/src | |
| parent | 0cd01aac6a80735cc936f75b45e3545a5273e2ad (diff) | |
| download | rust-aef0e346de744faeaa522b9c08562bb3e1814adc.tar.gz rust-aef0e346de744faeaa522b9c08562bb3e1814adc.zip | |
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.
Diffstat (limited to 'compiler/rustc_resolve/src')
| -rw-r--r-- | compiler/rustc_resolve/src/diagnostics.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/imports.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/rustdoc.rs | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 7c0405c87e0..bf7972e392c 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -149,7 +149,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { BuiltinLintDiag::AmbiguousGlobImports { diag }, ); } else { - let mut err = struct_span_code_err!(self.dcx(), diag.span, E0659, "{}", &diag.msg); + let mut err = struct_span_code_err!(self.dcx(), diag.span, E0659, "{}", diag.msg); report_ambiguity_error(&mut err, diag); err.emit(); } @@ -798,7 +798,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } ResolutionError::FailedToResolve { segment, label, suggestion, module } => { let mut err = - struct_span_code_err!(self.dcx(), span, E0433, "failed to resolve: {}", &label); + struct_span_code_err!(self.dcx(), span, E0433, "failed to resolve: {label}"); err.span_label(span, label); if let Some((suggestions, msg, applicability)) = suggestion { @@ -2893,7 +2893,7 @@ fn show_candidates( "" }; candidate.0 = - format!("{add_use}{}{append}{trailing}{additional_newline}", &candidate.0); + format!("{add_use}{}{append}{trailing}{additional_newline}", candidate.0); } match mode { diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 3896fe4c4fa..d05326ee311 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -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()); diff --git a/compiler/rustc_resolve/src/rustdoc.rs b/compiler/rustc_resolve/src/rustdoc.rs index 59460815321..4c49c15c472 100644 --- a/compiler/rustc_resolve/src/rustdoc.rs +++ b/compiler/rustc_resolve/src/rustdoc.rs @@ -339,7 +339,7 @@ pub fn strip_generics_from_path(path_str: &str) -> Result<Box<str>, MalformedGen } } - debug!("path_str: {:?}\nstripped segments: {:?}", path_str, &stripped_segments); + debug!("path_str: {path_str:?}\nstripped segments: {stripped_segments:?}"); let stripped_path = stripped_segments.join("::"); |
