From af3d75ad2e760dc885f54e6179543718ef8f141f Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Tue, 5 Jan 2021 00:22:42 +0800 Subject: Refactor TokenBuffer for reduc cloning --- crates/mbe/src/subtree_source.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'crates/mbe/src/subtree_source.rs') diff --git a/crates/mbe/src/subtree_source.rs b/crates/mbe/src/subtree_source.rs index d10d4b70e..36d6f1038 100644 --- a/crates/mbe/src/subtree_source.rs +++ b/crates/mbe/src/subtree_source.rs @@ -53,10 +53,12 @@ impl<'a> SubtreeTokenSource<'a> { fn is_lifetime(c: Cursor) -> Option<(Cursor, SmolStr)> { let tkn = c.token_tree(); - if let Some(tt::TokenTree::Leaf(tt::Leaf::Punct(punct))) = tkn { + if let Some(tt::buffer::TokenTreeRef::Leaf(tt::Leaf::Punct(punct), _)) = tkn { if punct.char == '\'' { let next = c.bump(); - if let Some(tt::TokenTree::Leaf(tt::Leaf::Ident(ident))) = next.token_tree() { + if let Some(tt::buffer::TokenTreeRef::Leaf(tt::Leaf::Ident(ident), _)) = + next.token_tree() + { let res_cursor = next.bump(); let text = SmolStr::new("'".to_string() + &ident.to_string()); @@ -94,11 +96,11 @@ impl<'a> SubtreeTokenSource<'a> { } match cursor.token_tree() { - Some(tt::TokenTree::Leaf(leaf)) => { + Some(tt::buffer::TokenTreeRef::Leaf(leaf, _)) => { cached.push(Some(convert_leaf(&leaf))); self.cached_cursor.set(cursor.bump()); } - Some(tt::TokenTree::Subtree(subtree)) => { + Some(tt::buffer::TokenTreeRef::Subtree(subtree, _)) => { self.cached_cursor.set(cursor.subtree().unwrap()); cached.push(Some(convert_delim(subtree.delimiter_kind(), false))); } -- cgit v1.2.3