diff options
-rw-r--r-- | crates/ra_mbe/src/syntax_bridge.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs index 9fb5cb058..31e9b22e7 100644 --- a/crates/ra_mbe/src/syntax_bridge.rs +++ b/crates/ra_mbe/src/syntax_bridge.rs | |||
@@ -607,12 +607,13 @@ impl<'a> TreeSink for TtTreeSink<'a> { | |||
607 | let text: SmolStr = match self.cursor.token_tree() { | 607 | let text: SmolStr = match self.cursor.token_tree() { |
608 | Some(tt::TokenTree::Leaf(leaf)) => { | 608 | Some(tt::TokenTree::Leaf(leaf)) => { |
609 | // Mark the range if needed | 609 | // Mark the range if needed |
610 | let id = match leaf { | 610 | let (text, id) = match leaf { |
611 | tt::Leaf::Ident(ident) => ident.id, | 611 | tt::Leaf::Ident(ident) => (ident.text.clone(), ident.id), |
612 | tt::Leaf::Punct(punct) => punct.id, | 612 | tt::Leaf::Punct(punct) => { |
613 | tt::Leaf::Literal(lit) => lit.id, | 613 | (SmolStr::new_inline_from_ascii(1, &[punct.char as u8]), punct.id) |
614 | } | ||
615 | tt::Leaf::Literal(lit) => (lit.text.clone(), lit.id), | ||
614 | }; | 616 | }; |
615 | let text = SmolStr::new(format!("{}", leaf)); | ||
616 | let range = TextRange::offset_len(self.text_pos, TextUnit::of_str(&text)); | 617 | let range = TextRange::offset_len(self.text_pos, TextUnit::of_str(&text)); |
617 | self.token_map.insert(id, range); | 618 | self.token_map.insert(id, range); |
618 | self.cursor = self.cursor.bump(); | 619 | self.cursor = self.cursor.bump(); |