aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-12-10 12:46:47 +0000
committerJonas Schievink <[email protected]>2020-12-10 12:46:47 +0000
commit948832d10ba2fe59c5c08c5642e5835a4d9922b9 (patch)
tree29964a543dcfdcae9fed97cc8c876028ce7e5256 /crates
parent06a03bab8e0fc76044da24e680582c47584041a9 (diff)
format_args: handle key-value arguments
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_expand/src/builtin_macro.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/crates/hir_expand/src/builtin_macro.rs b/crates/hir_expand/src/builtin_macro.rs
index f60666a54..477192a09 100644
--- a/crates/hir_expand/src/builtin_macro.rs
+++ b/crates/hir_expand/src/builtin_macro.rs
@@ -245,6 +245,12 @@ fn format_args_expand(
245 if args.is_empty() { 245 if args.is_empty() {
246 return ExpandResult::only_err(mbe::ExpandError::NoMatchingRule); 246 return ExpandResult::only_err(mbe::ExpandError::NoMatchingRule);
247 } 247 }
248 for arg in &mut args {
249 // Remove `key =`.
250 if matches!(arg.get(1), Some(tt::TokenTree::Leaf(tt::Leaf::Punct(p))) if p.char == '=') {
251 arg.drain(..2);
252 }
253 }
248 let _format_string = args.remove(0); 254 let _format_string = args.remove(0);
249 let arg_tts = args.into_iter().flat_map(|arg| { 255 let arg_tts = args.into_iter().flat_map(|arg| {
250 quote! { std::fmt::ArgumentV1::new(&(##arg), std::fmt::Display::fmt), } 256 quote! { std::fmt::ArgumentV1::new(&(##arg), std::fmt::Display::fmt), }