aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/nameres/collector.rs
diff options
context:
space:
mode:
authorSeivan Heidari <[email protected]>2019-11-11 13:31:09 +0000
committerSeivan Heidari <[email protected]>2019-11-11 13:31:09 +0000
commit68a5ff050faf514e9d122212a66703ca8ce66ab7 (patch)
tree0c389d2680aae82c1805a52f8315312724134341 /crates/ra_hir_def/src/nameres/collector.rs
parent7cd075ff0beb97039cd1d1c6c021abf89339731b (diff)
parenta599147b4232c0d4f6b071a3a96e86f903f4cf52 (diff)
Merge branch 'master' of https://github.com/rust-analyzer/rust-analyzer into feature/themes
Diffstat (limited to 'crates/ra_hir_def/src/nameres/collector.rs')
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs25
1 files changed, 23 insertions, 2 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 6db9937a4..37d0f3093 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -1,8 +1,9 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use hir_expand::{ 3use hir_expand::{
4 builtin_macro::find_builtin_macro,
4 name::{self, AsName, Name}, 5 name::{self, AsName, Name},
5 HirFileId, MacroCallId, MacroCallLoc, MacroDefId, MacroFileKind, 6 HirFileId, MacroCallId, MacroCallLoc, MacroDefId, MacroDefKind, MacroFileKind,
6}; 7};
7use ra_cfg::CfgOptions; 8use ra_cfg::CfgOptions;
8use ra_db::{CrateId, FileId}; 9use ra_db::{CrateId, FileId};
@@ -692,10 +693,30 @@ where
692 fn collect_macro(&mut self, mac: &raw::MacroData) { 693 fn collect_macro(&mut self, mac: &raw::MacroData) {
693 let ast_id = AstId::new(self.file_id, mac.ast_id); 694 let ast_id = AstId::new(self.file_id, mac.ast_id);
694 695
696 // Case 0: builtin macros
697 if mac.builtin {
698 if let Some(name) = &mac.name {
699 let krate = self.def_collector.def_map.krate;
700 if let Some(macro_id) = find_builtin_macro(name, krate, ast_id) {
701 self.def_collector.define_macro(
702 self.module_id,
703 name.clone(),
704 macro_id,
705 mac.export,
706 );
707 return;
708 }
709 }
710 }
711
695 // Case 1: macro rules, define a macro in crate-global mutable scope 712 // Case 1: macro rules, define a macro in crate-global mutable scope
696 if is_macro_rules(&mac.path) { 713 if is_macro_rules(&mac.path) {
697 if let Some(name) = &mac.name { 714 if let Some(name) = &mac.name {
698 let macro_id = MacroDefId { ast_id, krate: self.def_collector.def_map.krate }; 715 let macro_id = MacroDefId {
716 ast_id,
717 krate: self.def_collector.def_map.krate,
718 kind: MacroDefKind::Declarative,
719 };
699 self.def_collector.define_macro(self.module_id, name.clone(), macro_id, mac.export); 720 self.def_collector.define_macro(self.module_id, name.clone(), macro_id, mac.export);
700 } 721 }
701 return; 722 return;