diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-10 12:47:30 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-10 12:47:30 +0000 |
commit | 8d5da92e4c779e1222023295c3d29b18eafbdb99 (patch) | |
tree | 29964a543dcfdcae9fed97cc8c876028ce7e5256 | |
parent | 06a03bab8e0fc76044da24e680582c47584041a9 (diff) | |
parent | 948832d10ba2fe59c5c08c5642e5835a4d9922b9 (diff) |
Merge #6795
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 <[email protected]>
-rw-r--r-- | crates/hir_expand/src/builtin_macro.rs | 6 |
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), } |