From 70f2a21b55c1b09e575798a75807e13991f2cfec Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 9 Nov 2019 13:14:10 +0300 Subject: Remove typed macro parsing API We do type-erasure on every path anyway, so it doesn't make much sense to duplicate this function for every type --- crates/ra_hir_expand/src/db.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'crates/ra_hir_expand/src') 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; use mbe::MacroRules; use ra_db::{salsa, SourceDatabase}; +use ra_parser::FragmentKind; use ra_prof::profile; use ra_syntax::{AstNode, Parse, SyntaxNode}; @@ -108,12 +109,10 @@ pub(crate) fn parse_macro( }) .ok()?; - match macro_file.macro_file_kind { - MacroFileKind::Items => { - mbe::token_tree_to_items(&tt).ok().map(|(p, map)| (p.to_syntax(), Arc::new(map))) - } - MacroFileKind::Expr => { - mbe::token_tree_to_expr(&tt).ok().map(|(p, map)| (p.to_syntax(), Arc::new(map))) - } - } + let fragment_kind = match macro_file.macro_file_kind { + MacroFileKind::Items => FragmentKind::Items, + MacroFileKind::Expr => FragmentKind::Expr, + }; + let (parse, rev_token_map) = mbe::token_tree_to_syntax_node(&tt, fragment_kind).ok()?; + Some((parse, Arc::new(rev_token_map))) } -- cgit v1.2.3