diff options
Diffstat (limited to 'crates/ra_hir_expand/src')
-rw-r--r-- | crates/ra_hir_expand/src/proc_macro.rs | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/crates/ra_hir_expand/src/proc_macro.rs b/crates/ra_hir_expand/src/proc_macro.rs index a8dee2052..296325b05 100644 --- a/crates/ra_hir_expand/src/proc_macro.rs +++ b/crates/ra_hir_expand/src/proc_macro.rs | |||
@@ -1,33 +1,31 @@ | |||
1 | //! Proc Macro Expander stub | 1 | //! Proc Macro Expander stub |
2 | 2 | ||
3 | use crate::{db::AstDatabase, LazyMacroId, MacroCallKind, MacroCallLoc}; | 3 | use crate::{db::AstDatabase, LazyMacroId}; |
4 | use ra_db::CrateId; | 4 | use ra_db::{CrateId, ProcMacroId}; |
5 | 5 | ||
6 | #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] | 6 | #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] |
7 | pub struct ProcMacroExpander { | 7 | pub struct ProcMacroExpander { |
8 | krate: CrateId, | 8 | krate: CrateId, |
9 | proc_macro_id: ProcMacroId, | ||
9 | } | 10 | } |
10 | 11 | ||
11 | impl ProcMacroExpander { | 12 | impl ProcMacroExpander { |
12 | pub fn new(krate: CrateId) -> ProcMacroExpander { | 13 | pub fn new(krate: CrateId, proc_macro_id: ProcMacroId) -> ProcMacroExpander { |
13 | ProcMacroExpander { krate } | 14 | ProcMacroExpander { krate, proc_macro_id } |
14 | } | 15 | } |
15 | 16 | ||
16 | pub fn expand( | 17 | pub fn expand( |
17 | &self, | 18 | &self, |
18 | db: &dyn AstDatabase, | 19 | db: &dyn AstDatabase, |
19 | id: LazyMacroId, | 20 | _id: LazyMacroId, |
20 | _tt: &tt::Subtree, | 21 | tt: &tt::Subtree, |
21 | ) -> Result<tt::Subtree, mbe::ExpandError> { | 22 | ) -> Result<tt::Subtree, mbe::ExpandError> { |
22 | let loc: MacroCallLoc = db.lookup_intern_macro(id); | 23 | let krate_graph = db.crate_graph(); |
23 | let name = match loc.kind { | 24 | let proc_macro = krate_graph[self.krate] |
24 | MacroCallKind::FnLike(_) => return Err(mbe::ExpandError::ConversionError), | 25 | .proc_macro |
25 | MacroCallKind::Attr(_, name) => name, | 26 | .get(self.proc_macro_id.0) |
26 | }; | 27 | .clone() |
27 | 28 | .ok_or_else(|| mbe::ExpandError::ConversionError)?; | |
28 | log::debug!("Proc-macro-expanding name = {}", name); | 29 | proc_macro.custom_derive(tt) |
29 | |||
30 | // Return nothing for now | ||
31 | return Ok(tt::Subtree::default()); | ||
32 | } | 30 | } |
33 | } | 31 | } |