aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand/src/db.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_expand/src/db.rs')
-rw-r--r--crates/ra_hir_expand/src/db.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs
index 5a696542f..c2eb75ee5 100644
--- a/crates/ra_hir_expand/src/db.rs
+++ b/crates/ra_hir_expand/src/db.rs
@@ -11,7 +11,7 @@ use ra_syntax::{algo::diff, AstNode, Parse, SyntaxKind::*, SyntaxNode};
11use crate::{ 11use crate::{
12 ast_id_map::AstIdMap, BuiltinDeriveExpander, BuiltinFnLikeExpander, EagerCallLoc, EagerMacroId, 12 ast_id_map::AstIdMap, BuiltinDeriveExpander, BuiltinFnLikeExpander, EagerCallLoc, EagerMacroId,
13 HirFileId, HirFileIdRepr, LazyMacroId, MacroCallId, MacroCallLoc, MacroDefId, MacroDefKind, 13 HirFileId, HirFileIdRepr, LazyMacroId, MacroCallId, MacroCallLoc, MacroDefId, MacroDefKind,
14 MacroFile, 14 MacroFile, ProcMacroExpander,
15}; 15};
16 16
17#[derive(Debug, Clone, Eq, PartialEq)] 17#[derive(Debug, Clone, Eq, PartialEq)]
@@ -19,6 +19,7 @@ pub enum TokenExpander {
19 MacroRules(mbe::MacroRules), 19 MacroRules(mbe::MacroRules),
20 Builtin(BuiltinFnLikeExpander), 20 Builtin(BuiltinFnLikeExpander),
21 BuiltinDerive(BuiltinDeriveExpander), 21 BuiltinDerive(BuiltinDeriveExpander),
22 ProcMacro(ProcMacroExpander),
22} 23}
23 24
24impl TokenExpander { 25impl TokenExpander {
@@ -33,6 +34,7 @@ impl TokenExpander {
33 // FIXME switch these to ExpandResult as well 34 // FIXME switch these to ExpandResult as well
34 TokenExpander::Builtin(it) => it.expand(db, id, tt).into(), 35 TokenExpander::Builtin(it) => it.expand(db, id, tt).into(),
35 TokenExpander::BuiltinDerive(it) => it.expand(db, id, tt).into(), 36 TokenExpander::BuiltinDerive(it) => it.expand(db, id, tt).into(),
37 TokenExpander::ProcMacro(it) => it.expand(db, id, tt).into(),
36 } 38 }
37 } 39 }
38 40
@@ -41,6 +43,7 @@ impl TokenExpander {
41 TokenExpander::MacroRules(it) => it.map_id_down(id), 43 TokenExpander::MacroRules(it) => it.map_id_down(id),
42 TokenExpander::Builtin(..) => id, 44 TokenExpander::Builtin(..) => id,
43 TokenExpander::BuiltinDerive(..) => id, 45 TokenExpander::BuiltinDerive(..) => id,
46 TokenExpander::ProcMacro(..) => id,
44 } 47 }
45 } 48 }
46 49
@@ -49,6 +52,7 @@ impl TokenExpander {
49 TokenExpander::MacroRules(it) => it.map_id_up(id), 52 TokenExpander::MacroRules(it) => it.map_id_up(id),
50 TokenExpander::Builtin(..) => (id, mbe::Origin::Call), 53 TokenExpander::Builtin(..) => (id, mbe::Origin::Call),
51 TokenExpander::BuiltinDerive(..) => (id, mbe::Origin::Call), 54 TokenExpander::BuiltinDerive(..) => (id, mbe::Origin::Call),
55 TokenExpander::ProcMacro(..) => (id, mbe::Origin::Call),
52 } 56 }
53 } 57 }
54} 58}
@@ -130,7 +134,10 @@ pub(crate) fn macro_def(
130 MacroDefKind::BuiltInDerive(expander) => { 134 MacroDefKind::BuiltInDerive(expander) => {
131 Some(Arc::new((TokenExpander::BuiltinDerive(expander), mbe::TokenMap::default()))) 135 Some(Arc::new((TokenExpander::BuiltinDerive(expander), mbe::TokenMap::default())))
132 } 136 }
133 MacroDefKind::BuiltInEager(_expander) => None, 137 MacroDefKind::BuiltInEager(_) => None,
138 MacroDefKind::ProcMacro(expander) => {
139 Some(Arc::new((TokenExpander::ProcMacro(expander), mbe::TokenMap::default())))
140 }
134 } 141 }
135} 142}
136 143