Skip to content

Commit 72bba98

Browse files
committed
Merge empty delim subtree in proc-macro
1 parent da18f11 commit 72bba98

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

crates/ra_proc_macro_srv/src/rustc_server.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,16 @@ impl Extend<TokenTree> for TokenStream {
7676
impl Extend<TokenStream> for TokenStream {
7777
fn extend<I: IntoIterator<Item = TokenStream>>(&mut self, streams: I) {
7878
for item in streams {
79-
self.subtree.token_trees.extend(&mut item.into_iter())
79+
for tkn in item {
80+
match tkn {
81+
tt::TokenTree::Subtree(subtree) if subtree.delimiter.is_none() => {
82+
self.subtree.token_trees.extend(subtree.token_trees);
83+
}
84+
_ => {
85+
self.subtree.token_trees.push(tkn);
86+
}
87+
}
88+
}
8089
}
8190
}
8291
}

crates/ra_proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ SUBTREE $
2525
SUBTREE () 4294967295
2626
IDENT feature 4294967295
2727
PUNCH = [alone] 4294967295
28-
SUBTREE $
29-
LITERAL "cargo-clippy" 0
28+
LITERAL "cargo-clippy" 0
3029
PUNCH , [alone] 4294967295
3130
IDENT allow 4294967295
3231
SUBTREE () 4294967295

0 commit comments

Comments
 (0)