diff options
Diffstat (limited to 'crates/ra_mbe/src/syntax_bridge.rs')
-rw-r--r-- | crates/ra_mbe/src/syntax_bridge.rs | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs index 2dc04d4e7..9a2eceaba 100644 --- a/crates/ra_mbe/src/syntax_bridge.rs +++ b/crates/ra_mbe/src/syntax_bridge.rs | |||
@@ -23,23 +23,14 @@ fn convert_tt(tt: &SyntaxNode) -> Option<tt::Subtree> { | |||
23 | for char in child.leaf_text().unwrap().chars() { | 23 | for char in child.leaf_text().unwrap().chars() { |
24 | if let Some(char) = prev { | 24 | if let Some(char) = prev { |
25 | token_trees.push( | 25 | token_trees.push( |
26 | tt::Leaf::from(tt::Punct { | 26 | tt::Leaf::from(tt::Punct { char, spacing: tt::Spacing::Joint }).into(), |
27 | char, | ||
28 | spacing: tt::Spacing::Joint, | ||
29 | }) | ||
30 | .into(), | ||
31 | ); | 27 | ); |
32 | } | 28 | } |
33 | prev = Some(char) | 29 | prev = Some(char) |
34 | } | 30 | } |
35 | if let Some(char) = prev { | 31 | if let Some(char) = prev { |
36 | token_trees.push( | 32 | token_trees |
37 | tt::Leaf::from(tt::Punct { | 33 | .push(tt::Leaf::from(tt::Punct { char, spacing: tt::Spacing::Alone }).into()); |
38 | char, | ||
39 | spacing: tt::Spacing::Alone, | ||
40 | }) | ||
41 | .into(), | ||
42 | ); | ||
43 | } | 34 | } |
44 | } else { | 35 | } else { |
45 | let child: tt::TokenTree = if child.kind() == TOKEN_TREE { | 36 | let child: tt::TokenTree = if child.kind() == TOKEN_TREE { |
@@ -48,10 +39,7 @@ fn convert_tt(tt: &SyntaxNode) -> Option<tt::Subtree> { | |||
48 | let text = child.leaf_text().unwrap().clone(); | 39 | let text = child.leaf_text().unwrap().clone(); |
49 | tt::Leaf::from(tt::Ident { text }).into() | 40 | tt::Leaf::from(tt::Ident { text }).into() |
50 | } else if child.kind().is_literal() { | 41 | } else if child.kind().is_literal() { |
51 | tt::Leaf::from(tt::Literal { | 42 | tt::Leaf::from(tt::Literal { text: child.leaf_text().unwrap().clone() }).into() |
52 | text: child.leaf_text().unwrap().clone(), | ||
53 | }) | ||
54 | .into() | ||
55 | } else { | 43 | } else { |
56 | return None; | 44 | return None; |
57 | }; | 45 | }; |
@@ -59,9 +47,6 @@ fn convert_tt(tt: &SyntaxNode) -> Option<tt::Subtree> { | |||
59 | } | 47 | } |
60 | } | 48 | } |
61 | 49 | ||
62 | let res = tt::Subtree { | 50 | let res = tt::Subtree { delimiter, token_trees }; |
63 | delimiter, | ||
64 | token_trees, | ||
65 | }; | ||
66 | Some(res) | 51 | Some(res) |
67 | } | 52 | } |