From 30402beeb200fe85bd7595a6a8e6efdb81ede2b5 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sun, 28 Feb 2021 20:46:24 +0800 Subject: Fix assert split exprs on comma --- crates/hir_expand/src/builtin_macro.rs | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'crates/hir_expand/src/builtin_macro.rs') diff --git a/crates/hir_expand/src/builtin_macro.rs b/crates/hir_expand/src/builtin_macro.rs index 6fbb9570a..eb57ea7d6 100644 --- a/crates/hir_expand/src/builtin_macro.rs +++ b/crates/hir_expand/src/builtin_macro.rs @@ -182,25 +182,10 @@ fn assert_expand( // ```, // which is wrong but useful. - let mut args = Vec::new(); - let mut current = Vec::new(); - for tt in tt.token_trees.iter().cloned() { - match tt { - tt::TokenTree::Leaf(tt::Leaf::Punct(p)) if p.char == ',' => { - args.push(current); - current = Vec::new(); - } - _ => { - current.push(tt); - } - } - } - if !current.is_empty() { - args.push(current); - } + let args = parse_exprs_with_sep(tt, ','); let arg_tts = args.into_iter().flat_map(|arg| { - quote! { &(##arg), } + quote! { &(#arg), } }.token_trees).collect::>(); let expanded = quote! { -- cgit v1.2.3