From ce211434a6501e88cb83462f2443db085f1557d3 Mon Sep 17 00:00:00 2001 From: Lenard Pratt Date: Mon, 15 Apr 2019 11:01:29 +0100 Subject: Added macro resolution and expansion --- crates/ra_hir/src/nameres/collector.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir/src/nameres') diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs index 4590a5184..762a61604 100644 --- a/crates/ra_hir/src/nameres/collector.rs +++ b/crates/ra_hir/src/nameres/collector.rs @@ -131,6 +131,8 @@ where fn define_macro(&mut self, name: Name, macro_id: MacroDefId, export: bool) { if export { self.def_map.public_macros.insert(name.clone(), macro_id); + } else { + self.def_map.local_macros.insert(name.clone(), macro_id); } self.global_macro_scope.insert(name, macro_id); } @@ -517,10 +519,10 @@ where // Case 2: try to expand macro_rules from this crate, triggering // recursive item collection. - if let Some(¯o_id) = - mac.path.as_ident().and_then(|name| self.def_collector.global_macro_scope.get(name)) + if let Some(macro_id) = + mac.path.as_ident().and_then(|name| self.def_collector.global_macro_scope.get(&name)) { - let macro_call_id = MacroCallLoc { def: macro_id, ast_id }.id(self.def_collector.db); + let macro_call_id = MacroCallLoc { def: *macro_id, ast_id }.id(self.def_collector.db); self.def_collector.collect_macro_expansion(self.module_id, macro_call_id, macro_id); return; -- cgit v1.2.3 From 1ab7066e32ab482c70ea5c9bba7585eba275476a Mon Sep 17 00:00:00 2001 From: Lenard Pratt Date: Thu, 18 Apr 2019 19:35:47 +0100 Subject: Introduced resolve_macro_call on resolver changed to manual expansion fix for nested macros --- crates/ra_hir/src/nameres/collector.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir/src/nameres') diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs index 762a61604..b34c9b8e6 100644 --- a/crates/ra_hir/src/nameres/collector.rs +++ b/crates/ra_hir/src/nameres/collector.rs @@ -524,7 +524,7 @@ where { let macro_call_id = MacroCallLoc { def: *macro_id, ast_id }.id(self.def_collector.db); - self.def_collector.collect_macro_expansion(self.module_id, macro_call_id, macro_id); + self.def_collector.collect_macro_expansion(self.module_id, macro_call_id, *macro_id); return; } @@ -616,6 +616,7 @@ mod tests { modules, public_macros: FxHashMap::default(), poison_macros: FxHashSet::default(), + local_macros: FxHashMap::default(), diagnostics: Vec::new(), } }; -- cgit v1.2.3