aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_expand/src')
-rw-r--r--crates/ra_hir_expand/src/db.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs
index b789c6e7b..b4dafe1d8 100644
--- a/crates/ra_hir_expand/src/db.rs
+++ b/crates/ra_hir_expand/src/db.rs
@@ -4,6 +4,7 @@ use std::sync::Arc;
4 4
5use mbe::MacroRules; 5use mbe::MacroRules;
6use ra_db::{salsa, SourceDatabase}; 6use ra_db::{salsa, SourceDatabase};
7use ra_parser::FragmentKind;
7use ra_prof::profile; 8use ra_prof::profile;
8use ra_syntax::{AstNode, Parse, SyntaxNode}; 9use ra_syntax::{AstNode, Parse, SyntaxNode};
9 10
@@ -108,12 +109,10 @@ pub(crate) fn parse_macro(
108 }) 109 })
109 .ok()?; 110 .ok()?;
110 111
111 match macro_file.macro_file_kind { 112 let fragment_kind = match macro_file.macro_file_kind {
112 MacroFileKind::Items => { 113 MacroFileKind::Items => FragmentKind::Items,
113 mbe::token_tree_to_items(&tt).ok().map(|(p, map)| (p.to_syntax(), Arc::new(map))) 114 MacroFileKind::Expr => FragmentKind::Expr,
114 } 115 };
115 MacroFileKind::Expr => { 116 let (parse, rev_token_map) = mbe::token_tree_to_syntax_node(&tt, fragment_kind).ok()?;
116 mbe::token_tree_to_expr(&tt).ok().map(|(p, map)| (p.to_syntax(), Arc::new(map))) 117 Some((parse, Arc::new(rev_token_map)))
117 }
118 }
119} 118}