diff options
author | Edwin Cheng <[email protected]> | 2019-06-02 17:54:33 +0100 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-06-02 17:54:33 +0100 |
commit | 54ea251bd40bec06c28e635371588e83cdacca9b (patch) | |
tree | 51d6cef8d75b860ec41a1a4ba712ab0f2103f10b /crates/ra_mbe | |
parent | ccec71165bf1f8f79bd2d2a5c05bed55ff3a07a2 (diff) |
Store referece in tokenbuffer
Diffstat (limited to 'crates/ra_mbe')
-rw-r--r-- | crates/ra_mbe/src/subtree_parser.rs | 4 | ||||
-rw-r--r-- | crates/ra_mbe/src/syntax_bridge.rs | 6 |
2 files changed, 6 insertions, 4 deletions
diff --git a/crates/ra_mbe/src/subtree_parser.rs b/crates/ra_mbe/src/subtree_parser.rs index 1f12e42ef..4a6f6aa45 100644 --- a/crates/ra_mbe/src/subtree_parser.rs +++ b/crates/ra_mbe/src/subtree_parser.rs | |||
@@ -10,7 +10,7 @@ struct OffsetTokenSink<'a> { | |||
10 | } | 10 | } |
11 | 11 | ||
12 | impl<'a> OffsetTokenSink<'a> { | 12 | impl<'a> OffsetTokenSink<'a> { |
13 | pub fn collect(&self, begin: Cursor<'a>) -> Vec<tt::TokenTree> { | 13 | pub fn collect(&self, begin: Cursor<'a>) -> Vec<&'a tt::TokenTree> { |
14 | if !self.cursor.is_root() { | 14 | if !self.cursor.is_root() { |
15 | return vec![]; | 15 | return vec![]; |
16 | } | 16 | } |
@@ -114,7 +114,7 @@ impl<'a> Parser<'a> { | |||
114 | 1 => Some(res[0].clone()), | 114 | 1 => Some(res[0].clone()), |
115 | _ => Some(tt::TokenTree::Subtree(tt::Subtree { | 115 | _ => Some(tt::TokenTree::Subtree(tt::Subtree { |
116 | delimiter: tt::Delimiter::None, | 116 | delimiter: tt::Delimiter::None, |
117 | token_trees: res, | 117 | token_trees: res.into_iter().cloned().collect(), |
118 | })), | 118 | })), |
119 | } | 119 | } |
120 | } | 120 | } |
diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs index dce82f33d..0edb6f9a2 100644 --- a/crates/ra_mbe/src/syntax_bridge.rs +++ b/crates/ra_mbe/src/syntax_bridge.rs | |||
@@ -49,7 +49,8 @@ fn token_tree_to_syntax_node<F>(tt: &tt::Subtree, f: F) -> Result<TreeArc<Syntax | |||
49 | where | 49 | where |
50 | F: Fn(&mut ra_parser::TokenSource, &mut ra_parser::TreeSink), | 50 | F: Fn(&mut ra_parser::TokenSource, &mut ra_parser::TreeSink), |
51 | { | 51 | { |
52 | let buffer = TokenBuffer::new(&[tt.clone().into()]); | 52 | let tokens = [tt.clone().into()]; |
53 | let buffer = TokenBuffer::new(&tokens); | ||
53 | let mut token_source = SubtreeTokenSource::new(&buffer); | 54 | let mut token_source = SubtreeTokenSource::new(&buffer); |
54 | let mut tree_sink = TtTreeSink::new(buffer.begin()); | 55 | let mut tree_sink = TtTreeSink::new(buffer.begin()); |
55 | f(&mut token_source, &mut tree_sink); | 56 | f(&mut token_source, &mut tree_sink); |
@@ -385,7 +386,8 @@ mod tests { | |||
385 | "#, | 386 | "#, |
386 | ); | 387 | ); |
387 | let expansion = expand(&rules, "literals!(foo);"); | 388 | let expansion = expand(&rules, "literals!(foo);"); |
388 | let buffer = tt::buffer::TokenBuffer::new(&[expansion.clone().into()]); | 389 | let tts = &[expansion.clone().into()]; |
390 | let buffer = tt::buffer::TokenBuffer::new(tts); | ||
389 | let mut tt_src = SubtreeTokenSource::new(&buffer); | 391 | let mut tt_src = SubtreeTokenSource::new(&buffer); |
390 | let mut tokens = vec![]; | 392 | let mut tokens = vec![]; |
391 | while tt_src.current().kind != EOF { | 393 | while tt_src.current().kind != EOF { |