aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/nameres
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-04-23 13:49:31 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-04-23 13:49:31 +0100
commita094d5c621e44ff78dce953c0cae7cfba4b2840e (patch)
tree93d12337483968512db038b0b89aff7b9ef4eb20 /crates/ra_hir/src/nameres
parente2835b46f6928eda21b7edb44f305f20473a3a98 (diff)
parent1ab7066e32ab482c70ea5c9bba7585eba275476a (diff)
Merge #1147
1147: Handle macros in type checking / HIR r=matklad a=Lapz An other attempt at #1102. I will need to flatten the nested if statements and im also not sure if the way that i get the resolver and module will always work Co-authored-by: Lenard Pratt <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/nameres')
-rw-r--r--crates/ra_hir/src/nameres/collector.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs
index 4590a5184..b34c9b8e6 100644
--- a/crates/ra_hir/src/nameres/collector.rs
+++ b/crates/ra_hir/src/nameres/collector.rs
@@ -131,6 +131,8 @@ where
131 fn define_macro(&mut self, name: Name, macro_id: MacroDefId, export: bool) { 131 fn define_macro(&mut self, name: Name, macro_id: MacroDefId, export: bool) {
132 if export { 132 if export {
133 self.def_map.public_macros.insert(name.clone(), macro_id); 133 self.def_map.public_macros.insert(name.clone(), macro_id);
134 } else {
135 self.def_map.local_macros.insert(name.clone(), macro_id);
134 } 136 }
135 self.global_macro_scope.insert(name, macro_id); 137 self.global_macro_scope.insert(name, macro_id);
136 } 138 }
@@ -517,12 +519,12 @@ where
517 519
518 // Case 2: try to expand macro_rules from this crate, triggering 520 // Case 2: try to expand macro_rules from this crate, triggering
519 // recursive item collection. 521 // recursive item collection.
520 if let Some(&macro_id) = 522 if let Some(macro_id) =
521 mac.path.as_ident().and_then(|name| self.def_collector.global_macro_scope.get(name)) 523 mac.path.as_ident().and_then(|name| self.def_collector.global_macro_scope.get(&name))
522 { 524 {
523 let macro_call_id = MacroCallLoc { def: macro_id, ast_id }.id(self.def_collector.db); 525 let macro_call_id = MacroCallLoc { def: *macro_id, ast_id }.id(self.def_collector.db);
524 526
525 self.def_collector.collect_macro_expansion(self.module_id, macro_call_id, macro_id); 527 self.def_collector.collect_macro_expansion(self.module_id, macro_call_id, *macro_id);
526 return; 528 return;
527 } 529 }
528 530
@@ -614,6 +616,7 @@ mod tests {
614 modules, 616 modules,
615 public_macros: FxHashMap::default(), 617 public_macros: FxHashMap::default(),
616 poison_macros: FxHashSet::default(), 618 poison_macros: FxHashSet::default(),
619 local_macros: FxHashMap::default(),
617 diagnostics: Vec::new(), 620 diagnostics: Vec::new(),
618 } 621 }
619 }; 622 };