From c1c6e3ae7c6c1d268b1d0f608e58d74f863d572b Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 30 Aug 2022 17:26:50 +0200 Subject: [PATCH] Add clarifying comments. --- compiler/rustc_builtin_macros/src/format.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs index 1dd913ac6d2..26a9169a30b 100644 --- a/compiler/rustc_builtin_macros/src/format.rs +++ b/compiler/rustc_builtin_macros/src/format.rs @@ -308,12 +308,15 @@ pub fn make_format_args( .iter() .position(|arg| arg.1.ident().is_some_and(|id| id.name == name)) { + // Name found in `args`, so we resolve it to its index in that Vec. let index = start_of_named_args + i; if !matches!(args[index].1, FormatArgKind::Captured(_)) { + // Mark it as used, if it was an explicit argument. used[index] = true; } Ok(index) } else { + // Name not found in `args`, so we add it as an implicitly captured argument. let span = span.unwrap_or(fmt_span); let ident = Ident::new(name, span); let arg = if is_literal {