6795: format_args: handle key-value arguments r=jonas-schievink a=jonas-schievink

fixes https://github.com/rust-analyzer/rust-analyzer/issues/6728

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
bors[bot] 2020-12-10 12:47:30 +00:00 committed by GitHub
commit 8d5da92e4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -245,6 +245,12 @@ fn format_args_expand(
if args.is_empty() {
return ExpandResult::only_err(mbe::ExpandError::NoMatchingRule);
}
for arg in &mut args {
// Remove `key =`.
if matches!(arg.get(1), Some(tt::TokenTree::Leaf(tt::Leaf::Punct(p))) if p.char == '=') {
arg.drain(..2);
}
}
let _format_string = args.remove(0);
let arg_tts = args.into_iter().flat_map(|arg| {
quote! { std::fmt::ArgumentV1::new(&(##arg), std::fmt::Display::fmt), }