Skip to content

Commit a17c796

Browse files
committed
Auto merge of rust-lang#114264 - matthiaskrgr:rollup-dfsuu1v, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#98154 (merge functionality of `io::Sink` into `io::Empty`) - rust-lang#102198 (`const`-stablilize `NonNull::as_ref`) - rust-lang#114074 (inline format!() args from rustc_middle up to and including rustc_codegen_llvm (3)) - rust-lang#114246 (Weaken unnameable_types lint) - rust-lang#114256 (Fix invalid suggestion for mismatched types in closure arguments) - rust-lang#114258 (Simplify `Span::can_be_used_for_suggestions` a little tiny bit) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a8be6e0 + 4916ab5 commit a17c796

File tree

89 files changed

+614
-560
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+614
-560
lines changed

compiler/rustc_codegen_llvm/src/attributes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ pub fn from_fn_attrs<'ll, 'tcx>(
444444
let mut function_features = function_features
445445
.iter()
446446
.flat_map(|feat| {
447-
llvm_util::to_llvm_features(cx.tcx.sess, feat).into_iter().map(|f| format!("+{}", f))
447+
llvm_util::to_llvm_features(cx.tcx.sess, feat).into_iter().map(|f| format!("+{f}"))
448448
})
449449
.chain(codegen_fn_attrs.instruction_set.iter().map(|x| match x {
450450
InstructionSetAttr::ArmA32 => "-thumb-mode".to_string(),

compiler/rustc_codegen_llvm/src/back/archive.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn llvm_machine_type(cpu: &str) -> LLVMMachineType {
5656
"x86" => LLVMMachineType::I386,
5757
"aarch64" => LLVMMachineType::ARM64,
5858
"arm" => LLVMMachineType::ARM,
59-
_ => panic!("unsupported cpu type {}", cpu),
59+
_ => panic!("unsupported cpu type {cpu}"),
6060
}
6161
}
6262

@@ -128,7 +128,7 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
128128
let name_suffix = if is_direct_dependency { "_imports" } else { "_imports_indirect" };
129129
let output_path = {
130130
let mut output_path: PathBuf = tmpdir.to_path_buf();
131-
output_path.push(format!("{}{}", lib_name, name_suffix));
131+
output_path.push(format!("{lib_name}{name_suffix}"));
132132
output_path.with_extension("lib")
133133
};
134134

@@ -156,15 +156,15 @@ impl ArchiveBuilderBuilder for LlvmArchiveBuilderBuilder {
156156
// functions. Therefore, use binutils to create the import library instead,
157157
// by writing a .DEF file to the temp dir and calling binutils's dlltool.
158158
let def_file_path =
159-
tmpdir.join(format!("{}{}", lib_name, name_suffix)).with_extension("def");
159+
tmpdir.join(format!("{lib_name}{name_suffix}")).with_extension("def");
160160

161161
let def_file_content = format!(
162162
"EXPORTS\n{}",
163163
import_name_and_ordinal_vector
164164
.into_iter()
165165
.map(|(name, ordinal)| {
166166
match ordinal {
167-
Some(n) => format!("{} @{} NONAME", name, n),
167+
Some(n) => format!("{name} @{n} NONAME"),
168168
None => name,
169169
}
170170
})
@@ -435,7 +435,7 @@ impl<'a> LlvmArchiveBuilder<'a> {
435435
}
436436

437437
fn string_to_io_error(s: String) -> io::Error {
438-
io::Error::new(io::ErrorKind::Other, format!("bad archive: {}", s))
438+
io::Error::new(io::ErrorKind::Other, format!("bad archive: {s}"))
439439
}
440440

441441
fn find_binutils_dlltool(sess: &Session) -> OsString {

compiler/rustc_codegen_llvm/src/back/lto.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ fn fat_lto(
332332
let _timer = cgcx
333333
.prof
334334
.generic_activity_with_arg_recorder("LLVM_fat_lto_link_module", |recorder| {
335-
recorder.record_arg(format!("{:?}", name))
335+
recorder.record_arg(format!("{name:?}"))
336336
});
337337
info!("linking {:?}", name);
338338
let data = bc_decoded.data();
@@ -787,7 +787,7 @@ impl ThinLTOKeysMap {
787787
let file = File::create(path)?;
788788
let mut writer = io::BufWriter::new(file);
789789
for (module, key) in &self.keys {
790-
writeln!(writer, "{} {}", module, key)?;
790+
writeln!(writer, "{module} {key}")?;
791791
}
792792
Ok(())
793793
}
@@ -801,7 +801,7 @@ impl ThinLTOKeysMap {
801801
let mut split = line.split(' ');
802802
let module = split.next().unwrap();
803803
let key = split.next().unwrap();
804-
assert_eq!(split.next(), None, "Expected two space-separated values, found {:?}", line);
804+
assert_eq!(split.next(), None, "Expected two space-separated values, found {line:?}");
805805
keys.insert(module.to_string(), key.to_string());
806806
}
807807
Ok(Self { keys })

compiler/rustc_codegen_llvm/src/back/write.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ pub(crate) fn save_temp_bitcode(
259259
return;
260260
}
261261
unsafe {
262-
let ext = format!("{}.bc", name);
262+
let ext = format!("{name}.bc");
263263
let cgu = Some(&module.name[..]);
264264
let path = cgcx.output_filenames.temp_path_ext(&ext, cgu);
265265
let cstr = path_to_c_string(&path);
@@ -713,7 +713,7 @@ pub(crate) unsafe fn codegen(
713713

714714
let Ok(demangled) = rustc_demangle::try_demangle(input) else { return 0 };
715715

716-
if write!(cursor, "{:#}", demangled).is_err() {
716+
if write!(cursor, "{demangled:#}").is_err() {
717717
// Possible only if provided buffer is not big enough
718718
return 0;
719719
}
@@ -834,7 +834,7 @@ pub(crate) unsafe fn codegen(
834834
}
835835

836836
fn create_section_with_flags_asm(section_name: &str, section_flags: &str, data: &[u8]) -> Vec<u8> {
837-
let mut asm = format!(".section {},\"{}\"\n", section_name, section_flags).into_bytes();
837+
let mut asm = format!(".section {section_name},\"{section_flags}\"\n").into_bytes();
838838
asm.extend_from_slice(b".ascii \"");
839839
asm.reserve(data.len());
840840
for &byte in data {

compiler/rustc_codegen_llvm/src/builder.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -1415,9 +1415,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
14151415
) -> Cow<'b, [&'ll Value]> {
14161416
assert!(
14171417
self.cx.type_kind(fn_ty) == TypeKind::Function,
1418-
"builder::{} not passed a function, but {:?}",
1419-
typ,
1420-
fn_ty
1418+
"builder::{typ} not passed a function, but {fn_ty:?}"
14211419
);
14221420

14231421
let param_tys = self.cx.func_params_types(fn_ty);
@@ -1509,12 +1507,9 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
15091507

15101508
let instr = if signed { "fptosi" } else { "fptoui" };
15111509
let name = if let Some(vector_length) = vector_length {
1512-
format!(
1513-
"llvm.{}.sat.v{}i{}.v{}f{}",
1514-
instr, vector_length, int_width, vector_length, float_width
1515-
)
1510+
format!("llvm.{instr}.sat.v{vector_length}i{int_width}.v{vector_length}f{float_width}")
15161511
} else {
1517-
format!("llvm.{}.sat.i{}.f{}", instr, int_width, float_width)
1512+
format!("llvm.{instr}.sat.i{int_width}.f{float_width}")
15181513
};
15191514
let f = self.declare_cfn(&name, llvm::UnnamedAddr::No, self.type_func(&[src_ty], dest_ty));
15201515
self.call(self.type_func(&[src_ty], dest_ty), None, None, f, &[val], None)

compiler/rustc_codegen_llvm/src/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,10 @@ pub(crate) fn i686_decorated_name(
420420
DllCallingConvention::C => {}
421421
DllCallingConvention::Stdcall(arg_list_size)
422422
| DllCallingConvention::Fastcall(arg_list_size) => {
423-
write!(&mut decorated_name, "@{}", arg_list_size).unwrap();
423+
write!(&mut decorated_name, "@{arg_list_size}").unwrap();
424424
}
425425
DllCallingConvention::Vectorcall(arg_list_size) => {
426-
write!(&mut decorated_name, "@@{}", arg_list_size).unwrap();
426+
write!(&mut decorated_name, "@@{arg_list_size}").unwrap();
427427
}
428428
}
429429
}

compiler/rustc_codegen_llvm/src/consts.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,7 @@ impl<'ll> CodegenCx<'ll, '_> {
238238
assert!(
239239
!defined_in_current_codegen_unit,
240240
"consts::get_static() should always hit the cache for \
241-
statics defined in the same CGU, but did not for `{:?}`",
242-
def_id
241+
statics defined in the same CGU, but did not for `{def_id:?}`"
243242
);
244243

245244
let ty = instance.ty(self.tcx, ty::ParamEnv::reveal_all());

compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global<'ll>(cx: &CodegenCx<'ll, '
5454
// The initial byte `4` instructs GDB that the following pretty printer
5555
// is defined inline as opposed to in a standalone file.
5656
section_contents.extend_from_slice(b"\x04");
57-
let vis_name = format!("pretty-printer-{}-{}\n", crate_name, index);
57+
let vis_name = format!("pretty-printer-{crate_name}-{index}\n");
5858
section_contents.extend_from_slice(vis_name.as_bytes());
5959
section_contents.extend_from_slice(&visualizer.src);
6060

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
184184
debug_assert_eq!(
185185
(data_layout.pointer_size, data_layout.pointer_align.abi),
186186
cx.size_and_align_of(ptr_type),
187-
"ptr_type={}, pointee_type={}",
188-
ptr_type,
189-
pointee_type,
187+
"ptr_type={ptr_type}, pointee_type={pointee_type}",
190188
);
191189

192190
let di_node = unsafe {
@@ -521,7 +519,7 @@ fn recursion_marker_type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) -> &'ll D
521519
fn hex_encode(data: &[u8]) -> String {
522520
let mut hex_string = String::with_capacity(data.len() * 2);
523521
for byte in data.iter() {
524-
write!(&mut hex_string, "{:02x}", byte).unwrap();
522+
write!(&mut hex_string, "{byte:02x}").unwrap();
525523
}
526524
hex_string
527525
}
@@ -766,7 +764,7 @@ fn build_param_type_di_node<'ll, 'tcx>(
766764
t: Ty<'tcx>,
767765
) -> DINodeCreationResult<'ll> {
768766
debug!("build_param_type_di_node: {:?}", t);
769-
let name = format!("{:?}", t);
767+
let name = format!("{t:?}");
770768
DINodeCreationResult {
771769
di_node: unsafe {
772770
llvm::LLVMRustDIBuilderCreateBasicType(
@@ -814,7 +812,7 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
814812
debug!("build_compile_unit_di_node: {:?}", name_in_debuginfo);
815813
let rustc_producer = format!("rustc version {}", tcx.sess.cfg_version);
816814
// FIXME(#41252) Remove "clang LLVM" if we can get GDB and LLVM to play nice.
817-
let producer = format!("clang LLVM ({})", rustc_producer);
815+
let producer = format!("clang LLVM ({rustc_producer})");
818816

819817
let name_in_debuginfo = name_in_debuginfo.to_string_lossy();
820818
let work_dir = tcx.sess.opts.working_dir.to_string_lossy(FileNameDisplayPreference::Remapped);
@@ -1331,10 +1329,10 @@ fn build_vtable_type_di_node<'ll, 'tcx>(
13311329
// Note: This code does not try to give a proper name to each method
13321330
// because their might be multiple methods with the same name
13331331
// (coming from different traits).
1334-
(format!("__method{}", index), void_pointer_type_di_node)
1332+
(format!("__method{index}"), void_pointer_type_di_node)
13351333
}
13361334
ty::VtblEntry::TraitVPtr(_) => {
1337-
(format!("__super_trait_ptr{}", index), void_pointer_type_di_node)
1335+
(format!("__super_trait_ptr{index}"), void_pointer_type_di_node)
13381336
}
13391337
ty::VtblEntry::MetadataAlign => ("align".to_string(), usize_di_node),
13401338
ty::VtblEntry::MetadataSize => ("size".to_string(), usize_di_node),
@@ -1504,5 +1502,5 @@ pub fn tuple_field_name(field_index: usize) -> Cow<'static, str> {
15041502
TUPLE_FIELD_NAMES
15051503
.get(field_index)
15061504
.map(|s| Cow::from(*s))
1507-
.unwrap_or_else(|| Cow::from(format!("__{}", field_index)))
1505+
.unwrap_or_else(|| Cow::from(format!("__{field_index}")))
15081506
}

compiler/rustc_codegen_llvm/src/debuginfo/utils.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ pub(crate) fn fat_pointer_kind<'ll, 'tcx>(
9191
// For all other pointee types we should already have returned None
9292
// at the beginning of the function.
9393
panic!(
94-
"fat_pointer_kind() - Encountered unexpected `pointee_tail_ty`: {:?}",
95-
pointee_tail_ty
94+
"fat_pointer_kind() - Encountered unexpected `pointee_tail_ty`: {pointee_tail_ty:?}"
9695
)
9796
}
9897
}

compiler/rustc_codegen_llvm/src/intrinsic.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -230,36 +230,36 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
230230
sym::ctlz | sym::cttz => {
231231
let y = self.const_bool(false);
232232
self.call_intrinsic(
233-
&format!("llvm.{}.i{}", name, width),
233+
&format!("llvm.{name}.i{width}"),
234234
&[args[0].immediate(), y],
235235
)
236236
}
237237
sym::ctlz_nonzero => {
238238
let y = self.const_bool(true);
239-
let llvm_name = &format!("llvm.ctlz.i{}", width);
239+
let llvm_name = &format!("llvm.ctlz.i{width}");
240240
self.call_intrinsic(llvm_name, &[args[0].immediate(), y])
241241
}
242242
sym::cttz_nonzero => {
243243
let y = self.const_bool(true);
244-
let llvm_name = &format!("llvm.cttz.i{}", width);
244+
let llvm_name = &format!("llvm.cttz.i{width}");
245245
self.call_intrinsic(llvm_name, &[args[0].immediate(), y])
246246
}
247247
sym::ctpop => self.call_intrinsic(
248-
&format!("llvm.ctpop.i{}", width),
248+
&format!("llvm.ctpop.i{width}"),
249249
&[args[0].immediate()],
250250
),
251251
sym::bswap => {
252252
if width == 8 {
253253
args[0].immediate() // byte swap a u8/i8 is just a no-op
254254
} else {
255255
self.call_intrinsic(
256-
&format!("llvm.bswap.i{}", width),
256+
&format!("llvm.bswap.i{width}"),
257257
&[args[0].immediate()],
258258
)
259259
}
260260
}
261261
sym::bitreverse => self.call_intrinsic(
262-
&format!("llvm.bitreverse.i{}", width),
262+
&format!("llvm.bitreverse.i{width}"),
263263
&[args[0].immediate()],
264264
),
265265
sym::rotate_left | sym::rotate_right => {
@@ -1283,7 +1283,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
12831283
sym::simd_trunc => ("trunc", bx.type_func(&[vec_ty], vec_ty)),
12841284
_ => return_error!(InvalidMonomorphization::UnrecognizedIntrinsic { span, name }),
12851285
};
1286-
let llvm_name = &format!("llvm.{0}.v{1}{2}", intr_name, in_len, elem_ty_str);
1286+
let llvm_name = &format!("llvm.{intr_name}.v{in_len}{elem_ty_str}");
12871287
let f = bx.declare_cfn(llvm_name, llvm::UnnamedAddr::No, fn_ty);
12881288
let c = bx.call(
12891289
fn_ty,
@@ -1498,7 +1498,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
14981498
let llvm_elem_vec_str = llvm_vector_str(underlying_ty, in_len, pointer_count - 1, bx);
14991499

15001500
let llvm_intrinsic =
1501-
format!("llvm.masked.gather.{}.{}", llvm_elem_vec_str, llvm_pointer_vec_str);
1501+
format!("llvm.masked.gather.{llvm_elem_vec_str}.{llvm_pointer_vec_str}");
15021502
let fn_ty = bx.type_func(
15031503
&[llvm_pointer_vec_ty, alignment_ty, mask_ty, llvm_elem_vec_ty],
15041504
llvm_elem_vec_ty,
@@ -1642,7 +1642,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
16421642
let llvm_elem_vec_str = llvm_vector_str(underlying_ty, in_len, pointer_count - 1, bx);
16431643

16441644
let llvm_intrinsic =
1645-
format!("llvm.masked.scatter.{}.{}", llvm_elem_vec_str, llvm_pointer_vec_str);
1645+
format!("llvm.masked.scatter.{llvm_elem_vec_str}.{llvm_pointer_vec_str}");
16461646
let fn_ty =
16471647
bx.type_func(&[llvm_elem_vec_ty, llvm_pointer_vec_ty, alignment_ty, mask_ty], ret_t);
16481648
let f = bx.declare_cfn(&llvm_intrinsic, llvm::UnnamedAddr::No, fn_ty);

compiler/rustc_codegen_llvm/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -298,21 +298,21 @@ impl CodegenBackend for LlvmCodegenBackend {
298298
"ropi-rwpi",
299299
"default",
300300
] {
301-
writeln!(out, " {}", name);
301+
writeln!(out, " {name}");
302302
}
303303
writeln!(out);
304304
}
305305
PrintKind::CodeModels => {
306306
writeln!(out, "Available code models:");
307307
for name in &["tiny", "small", "kernel", "medium", "large"] {
308-
writeln!(out, " {}", name);
308+
writeln!(out, " {name}");
309309
}
310310
writeln!(out);
311311
}
312312
PrintKind::TlsModels => {
313313
writeln!(out, "Available TLS models:");
314314
for name in &["global-dynamic", "local-dynamic", "initial-exec", "local-exec"] {
315-
writeln!(out, " {}", name);
315+
writeln!(out, " {name}");
316316
}
317317
writeln!(out);
318318
}

compiler/rustc_codegen_llvm/src/llvm_util.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ pub fn target_features(sess: &Session, allow_unstable: bool) -> Vec<Symbol> {
315315

316316
pub fn print_version() {
317317
let (major, minor, patch) = get_version();
318-
println!("LLVM version: {}.{}.{}", major, minor, patch);
318+
println!("LLVM version: {major}.{minor}.{patch}");
319319
}
320320

321321
pub fn get_version() -> (u32, u32, u32) {
@@ -390,11 +390,11 @@ fn print_target_features(out: &mut dyn PrintBackendInfo, sess: &Session, tm: &ll
390390

391391
writeln!(out, "Features supported by rustc for this target:");
392392
for (feature, desc) in &rustc_target_features {
393-
writeln!(out, " {1:0$} - {2}.", max_feature_len, feature, desc);
393+
writeln!(out, " {feature:max_feature_len$} - {desc}.");
394394
}
395395
writeln!(out, "\nCode-generation features supported by LLVM for this target:");
396396
for (feature, desc) in &llvm_target_features {
397-
writeln!(out, " {1:0$} - {2}.", max_feature_len, feature, desc);
397+
writeln!(out, " {feature:max_feature_len$} - {desc}.");
398398
}
399399
if llvm_target_features.is_empty() {
400400
writeln!(out, " Target features listing is not supported by this LLVM version.");
@@ -573,7 +573,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
573573
match (enable_disable, feat) {
574574
('-' | '+', TargetFeatureFoldStrength::Both(f))
575575
| ('+', TargetFeatureFoldStrength::EnableOnly(f)) => {
576-
Some(format!("{}{}", enable_disable, f))
576+
Some(format!("{enable_disable}{f}"))
577577
}
578578
_ => None,
579579
}

0 commit comments

Comments
 (0)