diff options
Diffstat (limited to 'crates/ra_hir_expand/src/quote.rs')
-rw-r--r-- | crates/ra_hir_expand/src/quote.rs | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/crates/ra_hir_expand/src/quote.rs b/crates/ra_hir_expand/src/quote.rs index aa8a5f23f..49155fe62 100644 --- a/crates/ra_hir_expand/src/quote.rs +++ b/crates/ra_hir_expand/src/quote.rs | |||
@@ -16,7 +16,10 @@ macro_rules! __quote { | |||
16 | { | 16 | { |
17 | let children = $crate::__quote!($($tt)*); | 17 | let children = $crate::__quote!($($tt)*); |
18 | let subtree = tt::Subtree { | 18 | let subtree = tt::Subtree { |
19 | delimiter: Some(tt::Delimiter::$delim), | 19 | delimiter: Some(tt::Delimiter { |
20 | kind: tt::DelimiterKind::$delim, | ||
21 | id: tt::TokenId::unspecified(), | ||
22 | }), | ||
20 | token_trees: $crate::quote::IntoTt::to_tokens(children), | 23 | token_trees: $crate::quote::IntoTt::to_tokens(children), |
21 | }; | 24 | }; |
22 | subtree | 25 | subtree |
@@ -29,6 +32,7 @@ macro_rules! __quote { | |||
29 | tt::Leaf::Punct(tt::Punct { | 32 | tt::Leaf::Punct(tt::Punct { |
30 | char: $first, | 33 | char: $first, |
31 | spacing: tt::Spacing::Alone, | 34 | spacing: tt::Spacing::Alone, |
35 | id: tt::TokenId::unspecified(), | ||
32 | }).into() | 36 | }).into() |
33 | ] | 37 | ] |
34 | } | 38 | } |
@@ -40,10 +44,12 @@ macro_rules! __quote { | |||
40 | tt::Leaf::Punct(tt::Punct { | 44 | tt::Leaf::Punct(tt::Punct { |
41 | char: $first, | 45 | char: $first, |
42 | spacing: tt::Spacing::Joint, | 46 | spacing: tt::Spacing::Joint, |
47 | id: tt::TokenId::unspecified(), | ||
43 | }).into(), | 48 | }).into(), |
44 | tt::Leaf::Punct(tt::Punct { | 49 | tt::Leaf::Punct(tt::Punct { |
45 | char: $sec, | 50 | char: $sec, |
46 | spacing: tt::Spacing::Alone, | 51 | spacing: tt::Spacing::Alone, |
52 | id: tt::TokenId::unspecified(), | ||
47 | }).into() | 53 | }).into() |
48 | ] | 54 | ] |
49 | } | 55 | } |
@@ -179,15 +185,15 @@ macro_rules! impl_to_to_tokentrees { | |||
179 | } | 185 | } |
180 | 186 | ||
181 | impl_to_to_tokentrees! { | 187 | impl_to_to_tokentrees! { |
182 | u32 => self { tt::Literal{text: self.to_string().into()} }; | 188 | u32 => self { tt::Literal{text: self.to_string().into(), id: tt::TokenId::unspecified()} }; |
183 | usize => self { tt::Literal{text: self.to_string().into()}}; | 189 | usize => self { tt::Literal{text: self.to_string().into(), id: tt::TokenId::unspecified()}}; |
184 | i32 => self { tt::Literal{text: self.to_string().into()}}; | 190 | i32 => self { tt::Literal{text: self.to_string().into(), id: tt::TokenId::unspecified()}}; |
185 | tt::Leaf => self { self }; | 191 | tt::Leaf => self { self }; |
186 | tt::Literal => self { self }; | 192 | tt::Literal => self { self }; |
187 | tt::Ident => self { self }; | 193 | tt::Ident => self { self }; |
188 | tt::Punct => self { self }; | 194 | tt::Punct => self { self }; |
189 | &str => self { tt::Literal{text: format!("{:?}", self.escape_default().to_string()).into()}}; | 195 | &str => self { tt::Literal{text: format!("{:?}", self.escape_default().to_string()).into(), id: tt::TokenId::unspecified()}}; |
190 | String => self { tt::Literal{text: format!("{:?}", self.escape_default().to_string()).into()}} | 196 | String => self { tt::Literal{text: format!("{:?}", self.escape_default().to_string()).into(), id: tt::TokenId::unspecified()}} |
191 | } | 197 | } |
192 | 198 | ||
193 | #[cfg(test)] | 199 | #[cfg(test)] |
@@ -254,8 +260,13 @@ mod tests { | |||
254 | let fields = | 260 | let fields = |
255 | fields.iter().map(|it| quote!(#it: self.#it.clone(), ).token_trees.clone()).flatten(); | 261 | fields.iter().map(|it| quote!(#it: self.#it.clone(), ).token_trees.clone()).flatten(); |
256 | 262 | ||
257 | let list = | 263 | let list = tt::Subtree { |
258 | tt::Subtree { delimiter: Some(tt::Delimiter::Brace), token_trees: fields.collect() }; | 264 | delimiter: Some(tt::Delimiter { |
265 | kind: tt::DelimiterKind::Brace, | ||
266 | id: tt::TokenId::unspecified(), | ||
267 | }), | ||
268 | token_trees: fields.collect(), | ||
269 | }; | ||
259 | 270 | ||
260 | let quoted = quote! { | 271 | let quoted = quote! { |
261 | impl Clone for #struct_name { | 272 | impl Clone for #struct_name { |