inline format!() args up to and including rustc_codegen_llvm

This commit is contained in:
Matthias Krüger 2023-07-25 23:04:01 +02:00
parent 2e0136a131
commit 3ce90b1649
72 changed files with 411 additions and 481 deletions

View file

@ -56,7 +56,7 @@ fn llvm_machine_type(cpu: &str) -> LLVMMachineType {
"x86" => LLVMMachineType::I386,
"aarch64" => LLVMMachineType::ARM64,
"arm" => LLVMMachineType::ARM,
_ => panic!("unsupported cpu type {}", cpu),
_ => panic!("unsupported cpu type {cpu}"),
}
}
@ -128,7 +128,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
let name_suffix = if is_direct_dependency { "_imports" } else { "_imports_indirect" };
let output_path = {
let mut output_path: PathBuf = tmpdir.to_path_buf();
output_path.push(format!("{}{}", lib_name, name_suffix));
output_path.push(format!("{lib_name}{name_suffix}"));
output_path.with_extension("lib")
};
@ -156,7 +156,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
// functions. Therefore, use binutils to create the import library instead,
// by writing a .DEF file to the temp dir and calling binutils's dlltool.
let def_file_path =
tmpdir.join(format!("{}{}", lib_name, name_suffix)).with_extension("def");
tmpdir.join(format!("{lib_name}{name_suffix}")).with_extension("def");
let def_file_content = format!(
"EXPORTS\n{}",
@ -164,7 +164,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
.into_iter()
.map(|(name, ordinal)| {
match ordinal {
Some(n) => format!("{} @{} NONAME", name, n),
Some(n) => format!("{name} @{n} NONAME"),
None => name,
}
})
@ -435,7 +435,7 @@ impl<'a> LlvmArchiveBuilder<'a> {
}
fn string_to_io_error(s: String) -> io::Error {
io::Error::new(io::ErrorKind::Other, format!("bad archive: {}", s))
io::Error::new(io::ErrorKind::Other, format!("bad archive: {s}"))
}
fn find_binutils_dlltool(sess: &Session) -> OsString {

View file

@ -332,7 +332,7 @@ fn fat_lto(
let _timer = cgcx
.prof
.generic_activity_with_arg_recorder("LLVM_fat_lto_link_module", |recorder| {
recorder.record_arg(format!("{:?}", name))
recorder.record_arg(format!("{name:?}"))
});
info!("linking {:?}", name);
let data = bc_decoded.data();
@ -787,7 +787,7 @@ impl ThinLTOKeysMap {
let file = File::create(path)?;
let mut writer = io::BufWriter::new(file);
for (module, key) in &self.keys {
writeln!(writer, "{} {}", module, key)?;
writeln!(writer, "{module} {key}")?;
}
Ok(())
}
@ -801,7 +801,7 @@ impl ThinLTOKeysMap {
let mut split = line.split(' ');
let module = split.next().unwrap();
let key = split.next().unwrap();
assert_eq!(split.next(), None, "Expected two space-separated values, found {:?}", line);
assert_eq!(split.next(), None, "Expected two space-separated values, found {line:?}");
keys.insert(module.to_string(), key.to_string());
}
Ok(Self { keys })

View file

@ -259,7 +259,7 @@ pub(crate) fn save_temp_bitcode(
return;
}
unsafe {
let ext = format!("{}.bc", name);
let ext = format!("{name}.bc");
let cgu = Some(&module.name[..]);
let path = cgcx.output_filenames.temp_path_ext(&ext, cgu);
let cstr = path_to_c_string(&path);
@ -713,7 +713,7 @@ pub(crate) unsafe fn codegen(
let Ok(demangled) = rustc_demangle::try_demangle(input) else { return 0 };
if write!(cursor, "{:#}", demangled).is_err() {
if write!(cursor, "{demangled:#}").is_err() {
// Possible only if provided buffer is not big enough
return 0;
}
@ -834,7 +834,7 @@ pub(crate) unsafe fn codegen(
}
fn create_section_with_flags_asm(section_name: &str, section_flags: &str, data: &[u8]) -> Vec<u8> {
let mut asm = format!(".section {},\"{}\"\n", section_name, section_flags).into_bytes();
let mut asm = format!(".section {section_name},\"{section_flags}\"\n").into_bytes();
asm.extend_from_slice(b".ascii \"");
asm.reserve(data.len());
for &byte in data {