about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-02-02 13:38:43 +0000
committerbors <bors@rust-lang.org>2025-02-02 13:38:43 +0000
commite1f09207fb273b10fee01c0bef1b2c6130eaea80 (patch)
treea13e99fb98a5b045ac2921090302569b015eb140 /compiler/rustc_builtin_macros/src
parent6dd75f0d6802f56564f5f9c947a85ded286d3986 (diff)
parent44def58274eb0bea097a1e7f545b06800c7dcdc4 (diff)
downloadrust-e1f09207fb273b10fee01c0bef1b2c6130eaea80.tar.gz
rust-e1f09207fb273b10fee01c0bef1b2c6130eaea80.zip
Auto merge of #136433 - matthiaskrgr:rollup-co27itw, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #133266 (ci: fix explanation why LLVM download is disabled for windows-gnu)
 - #136133 (Fix sentence in process::abort)
 - #136279 (Rename `tcx.ensure()` to `tcx.ensure_ok()`, and improve the associated docs)
 - #136328 (Rework "long type names" printing logic)
 - #136358 (`#[optimize(none)]` implies `#[inline(never)]`)
 - #136368 (Make comma separated lists of anything easier to make for errors)
 - #136412 (Tweak fn pointer suggestion span)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_builtin_macros/src')
-rw-r--r--compiler/rustc_builtin_macros/src/format.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs
index 7c746bd719f..90447da6680 100644
--- a/compiler/rustc_builtin_macros/src/format.rs
+++ b/compiler/rustc_builtin_macros/src/format.rs
@@ -8,7 +8,9 @@ use rustc_ast::{
     token,
 };
 use rustc_data_structures::fx::FxHashSet;
-use rustc_errors::{Applicability, Diag, MultiSpan, PResult, SingleLabelManySpans};
+use rustc_errors::{
+    Applicability, Diag, MultiSpan, PResult, SingleLabelManySpans, listify, pluralize,
+};
 use rustc_expand::base::*;
 use rustc_lint_defs::builtin::NAMED_ARGUMENTS_USED_POSITIONALLY;
 use rustc_lint_defs::{BufferedEarlyLint, BuiltinLintDiag, LintId};
@@ -975,15 +977,11 @@ fn report_invalid_references(
         } else {
             MultiSpan::from_spans(invalid_refs.iter().filter_map(|&(_, span, _, _)| span).collect())
         };
-        let arg_list = if let &[index] = &indexes[..] {
-            format!("argument {index}")
-        } else {
-            let tail = indexes.pop().unwrap();
-            format!(
-                "arguments {head} and {tail}",
-                head = indexes.into_iter().map(|i| i.to_string()).collect::<Vec<_>>().join(", ")
-            )
-        };
+        let arg_list = format!(
+            "argument{} {}",
+            pluralize!(indexes.len()),
+            listify(&indexes, |i: &usize| i.to_string()).unwrap_or_default()
+        );
         e = ecx.dcx().struct_span_err(
             span,
             format!("invalid reference to positional {arg_list} ({num_args_desc})"),