Add clarifying comments.

This commit is contained in:
Mara Bos 2022-08-30 17:26:50 +02:00
parent 8d9a5881ea
commit c1c6e3ae7c

View File

@ -308,12 +308,15 @@ pub fn make_format_args(
.iter() .iter()
.position(|arg| arg.1.ident().is_some_and(|id| id.name == name)) .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; let index = start_of_named_args + i;
if !matches!(args[index].1, FormatArgKind::Captured(_)) { if !matches!(args[index].1, FormatArgKind::Captured(_)) {
// Mark it as used, if it was an explicit argument.
used[index] = true; used[index] = true;
} }
Ok(index) Ok(index)
} else { } else {
// Name not found in `args`, so we add it as an implicitly captured argument.
let span = span.unwrap_or(fmt_span); let span = span.unwrap_or(fmt_span);
let ident = Ident::new(name, span); let ident = Ident::new(name, span);
let arg = if is_literal { let arg = if is_literal {