diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-09 08:43:07 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-09 08:43:07 +0000 |
commit | 0363c9495a6a07db276dce4c67fa35fbfc20153c (patch) | |
tree | 0a98e2b4659d0d0f4df98f41613c6da90e19551f /crates/ra_hir_expand | |
parent | 7ac99aad28a36e7cdb27edcb319d7f540dbd8471 (diff) | |
parent | e7206467d57c555f1ca1fee6acc0461d7579f4f7 (diff) |
Merge #3518
3518: Add parse_to_token_tree r=matklad a=edwin0cheng
This PR introduce a function for parsing `&str` to `tt::TokenTree`:
```rust
// Convert a string to a `TokenTree`
pub fn parse_to_token_tree(text: &str) -> Option<(tt::Subtree, TokenMap)> {
````
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir_expand')
-rw-r--r-- | crates/ra_hir_expand/src/builtin_macro.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs index 9bc33cfa8..3f60b1cca 100644 --- a/crates/ra_hir_expand/src/builtin_macro.rs +++ b/crates/ra_hir_expand/src/builtin_macro.rs | |||
@@ -7,6 +7,7 @@ use crate::{ | |||
7 | 7 | ||
8 | use crate::{quote, EagerMacroId, LazyMacroId, MacroCallId}; | 8 | use crate::{quote, EagerMacroId, LazyMacroId, MacroCallId}; |
9 | use either::Either; | 9 | use either::Either; |
10 | use mbe::parse_to_token_tree; | ||
10 | use ra_db::{FileId, RelativePath}; | 11 | use ra_db::{FileId, RelativePath}; |
11 | use ra_parser::FragmentKind; | 12 | use ra_parser::FragmentKind; |
12 | 13 | ||
@@ -306,10 +307,9 @@ fn include_expand( | |||
306 | 307 | ||
307 | // FIXME: | 308 | // FIXME: |
308 | // Handle include as expression | 309 | // Handle include as expression |
309 | let node = | 310 | let res = parse_to_token_tree(&db.file_text(file_id.into())) |
310 | db.parse_or_expand(file_id.into()).ok_or_else(|| mbe::ExpandError::ConversionError)?; | 311 | .ok_or_else(|| mbe::ExpandError::ConversionError)? |
311 | let res = | 312 | .0; |
312 | mbe::syntax_node_to_token_tree(&node).ok_or_else(|| mbe::ExpandError::ConversionError)?.0; | ||
313 | 313 | ||
314 | Ok((res, FragmentKind::Items)) | 314 | Ok((res, FragmentKind::Items)) |
315 | } | 315 | } |