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
0cd01aac6a
commit
aef0e346de
23 changed files with 61 additions and 65 deletions
|
@ -759,7 +759,7 @@ fn link_natively(
|
|||
sess.dcx().abort_if_errors();
|
||||
|
||||
// Invoke the system linker
|
||||
info!("{:?}", &cmd);
|
||||
info!("{cmd:?}");
|
||||
let retry_on_segfault = env::var("RUSTC_RETRY_LINKER_ON_SEGFAULT").is_ok();
|
||||
let unknown_arg_regex =
|
||||
Regex::new(r"(unknown|unrecognized) (command line )?(option|argument)").unwrap();
|
||||
|
@ -796,7 +796,7 @@ fn link_natively(
|
|||
cmd.arg(arg);
|
||||
}
|
||||
}
|
||||
info!("{:?}", &cmd);
|
||||
info!("{cmd:?}");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -817,7 +817,7 @@ fn link_natively(
|
|||
cmd.arg(arg);
|
||||
}
|
||||
}
|
||||
info!("{:?}", &cmd);
|
||||
info!("{cmd:?}");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -878,7 +878,7 @@ fn link_natively(
|
|||
cmd.arg(arg);
|
||||
}
|
||||
}
|
||||
info!("{:?}", &cmd);
|
||||
info!("{cmd:?}");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -996,7 +996,7 @@ fn link_natively(
|
|||
sess.dcx().emit_err(errors::UnableToExeLinker {
|
||||
linker_path,
|
||||
error: e,
|
||||
command_formatted: format!("{:?}", &cmd),
|
||||
command_formatted: format!("{cmd:?}"),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1567,7 +1567,7 @@ fn print_native_static_libs(
|
|||
sess.dcx().emit_note(errors::StaticLibraryNativeArtifacts);
|
||||
// Prefix for greppability
|
||||
// Note: This must not be translated as tools are allowed to depend on this exact string.
|
||||
sess.dcx().note(format!("native-static-libs: {}", &lib_args.join(" ")));
|
||||
sess.dcx().note(format!("native-static-libs: {}", lib_args.join(" ")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -328,7 +328,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
|||
sym::link_section => {
|
||||
if let Some(val) = attr.value_str() {
|
||||
if val.as_str().bytes().any(|b| b == 0) {
|
||||
let msg = format!("illegal null byte in link_section value: `{}`", &val);
|
||||
let msg = format!("illegal null byte in link_section value: `{val}`");
|
||||
tcx.dcx().span_err(attr.span, msg);
|
||||
} else {
|
||||
codegen_fn_attrs.link_section = Some(val);
|
||||
|
@ -726,7 +726,7 @@ fn check_link_ordinal(tcx: TyCtxt<'_>, attr: &ast::Attribute) -> Option<u16> {
|
|||
if *ordinal <= u16::MAX as u128 {
|
||||
Some(ordinal.get() as u16)
|
||||
} else {
|
||||
let msg = format!("ordinal value in `link_ordinal` is too large: `{}`", &ordinal);
|
||||
let msg = format!("ordinal value in `link_ordinal` is too large: `{ordinal}`");
|
||||
tcx.dcx()
|
||||
.struct_span_err(attr.span, msg)
|
||||
.with_note("the value may not exceed `u16::MAX`")
|
||||
|
|
|
@ -130,7 +130,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
|
|||
|
||||
let symbol_name = self.symbol_name(cx.tcx()).name;
|
||||
|
||||
debug!("symbol {}", &symbol_name);
|
||||
debug!("symbol {symbol_name}");
|
||||
|
||||
match *self {
|
||||
MonoItem::Static(def_id) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue