aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_mbe/src/mbe_expander.rs4
-rw-r--r--crates/ra_mbe/src/mbe_parser.rs2
-rw-r--r--crates/ra_mbe/src/syntax_bridge.rs2
-rw-r--r--crates/ra_tt/src/lib.rs10
4 files changed, 15 insertions, 3 deletions
diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs
index eec713d9c..f6177f078 100644
--- a/crates/ra_mbe/src/mbe_expander.rs
+++ b/crates/ra_mbe/src/mbe_expander.rs
@@ -3,6 +3,7 @@
3/// `tt::TokenTree` for the result of the expansion. 3/// `tt::TokenTree` for the result of the expansion.
4use rustc_hash::FxHashMap; 4use rustc_hash::FxHashMap;
5use ra_syntax::SmolStr; 5use ra_syntax::SmolStr;
6use tt::TokenId;
6 7
7use crate::tt_cursor::TtCursor; 8use crate::tt_cursor::TtCursor;
8 9
@@ -185,7 +186,8 @@ fn expand_tt(
185 } 186 }
186 crate::TokenTree::Leaf(leaf) => match leaf { 187 crate::TokenTree::Leaf(leaf) => match leaf {
187 crate::Leaf::Ident(ident) => { 188 crate::Leaf::Ident(ident) => {
188 tt::Leaf::from(tt::Ident { text: ident.text.clone() }).into() 189 tt::Leaf::from(tt::Ident { text: ident.text.clone(), id: TokenId::unspecified() })
190 .into()
189 } 191 }
190 crate::Leaf::Punct(punct) => tt::Leaf::from(punct.clone()).into(), 192 crate::Leaf::Punct(punct) => tt::Leaf::from(punct.clone()).into(),
191 crate::Leaf::Var(v) => bindings.get(&v.text, nesting)?.clone(), 193 crate::Leaf::Var(v) => bindings.get(&v.text, nesting)?.clone(),
diff --git a/crates/ra_mbe/src/mbe_parser.rs b/crates/ra_mbe/src/mbe_parser.rs
index 60e566ed2..58e2533f1 100644
--- a/crates/ra_mbe/src/mbe_parser.rs
+++ b/crates/ra_mbe/src/mbe_parser.rs
@@ -41,7 +41,7 @@ fn parse_subtree(tt: &tt::Subtree) -> Option<crate::Subtree> {
41 } 41 }
42 } 42 }
43 tt::Leaf::Punct(punct) => crate::Leaf::from(*punct).into(), 43 tt::Leaf::Punct(punct) => crate::Leaf::from(*punct).into(),
44 tt::Leaf::Ident(tt::Ident { text }) => { 44 tt::Leaf::Ident(tt::Ident { text, id: _ }) => {
45 crate::Leaf::from(crate::Ident { text: text.clone() }).into() 45 crate::Leaf::from(crate::Ident { text: text.clone() }).into()
46 } 46 }
47 tt::Leaf::Literal(tt::Literal { text }) => { 47 tt::Leaf::Literal(tt::Literal { text }) => {
diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs
index 9a2eceaba..d734f5597 100644
--- a/crates/ra_mbe/src/syntax_bridge.rs
+++ b/crates/ra_mbe/src/syntax_bridge.rs
@@ -37,7 +37,7 @@ fn convert_tt(tt: &SyntaxNode) -> Option<tt::Subtree> {
37 convert_tt(child)?.into() 37 convert_tt(child)?.into()
38 } else if child.kind().is_keyword() || child.kind() == IDENT { 38 } else if child.kind().is_keyword() || child.kind() == IDENT {
39 let text = child.leaf_text().unwrap().clone(); 39 let text = child.leaf_text().unwrap().clone();
40 tt::Leaf::from(tt::Ident { text }).into() 40 tt::Leaf::from(tt::Ident { text, id: tt::TokenId::unspecified() }).into()
41 } else if child.kind().is_literal() { 41 } else if child.kind().is_literal() {
42 tt::Leaf::from(tt::Literal { text: child.leaf_text().unwrap().clone() }).into() 42 tt::Leaf::from(tt::Literal { text: child.leaf_text().unwrap().clone() }).into()
43 } else { 43 } else {
diff --git a/crates/ra_tt/src/lib.rs b/crates/ra_tt/src/lib.rs
index df31f72f3..e0a4cdb8b 100644
--- a/crates/ra_tt/src/lib.rs
+++ b/crates/ra_tt/src/lib.rs
@@ -18,6 +18,15 @@ use std::fmt;
18 18
19use smol_str::SmolStr; 19use smol_str::SmolStr;
20 20
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
22pub struct TokenId(pub u32);
23
24impl TokenId {
25 pub const fn unspecified() -> TokenId {
26 TokenId(!0)
27 }
28}
29
21#[derive(Debug, Clone)] 30#[derive(Debug, Clone)]
22pub enum TokenTree { 31pub enum TokenTree {
23 Leaf(Leaf), 32 Leaf(Leaf),
@@ -67,6 +76,7 @@ pub enum Spacing {
67#[derive(Debug, Clone)] 76#[derive(Debug, Clone)]
68pub struct Ident { 77pub struct Ident {
69 pub text: SmolStr, 78 pub text: SmolStr,
79 pub id: TokenId,
70} 80}
71 81
72impl fmt::Display for TokenTree { 82impl fmt::Display for TokenTree {