aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/nameres
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-10-29 08:15:51 +0000
committerAleksey Kladov <[email protected]>2019-10-29 08:15:51 +0000
commit77f90caf2deeb6a2d2c8196399fbba61bf0c461d (patch)
tree09667ecbdcc8b84916c509d3a3d09ab56b5d4aed /crates/ra_hir/src/nameres
parent120000609ab0a0e6a946404d0477f5a0a7107800 (diff)
start ra_hir_def crate
Diffstat (limited to 'crates/ra_hir/src/nameres')
-rw-r--r--crates/ra_hir/src/nameres/collector.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs
index b5fe16bfa..4f363df36 100644
--- a/crates/ra_hir/src/nameres/collector.rs
+++ b/crates/ra_hir/src/nameres/collector.rs
@@ -567,7 +567,7 @@ where
567 // inline module, just recurse 567 // inline module, just recurse
568 raw::ModuleData::Definition { name, items, ast_id } => { 568 raw::ModuleData::Definition { name, items, ast_id } => {
569 let module_id = 569 let module_id =
570 self.push_child_module(name.clone(), ast_id.with_file_id(self.file_id), None); 570 self.push_child_module(name.clone(), AstId::new(self.file_id, *ast_id), None);
571 571
572 ModCollector { 572 ModCollector {
573 def_collector: &mut *self.def_collector, 573 def_collector: &mut *self.def_collector,
@@ -583,7 +583,7 @@ where
583 } 583 }
584 // out of line module, resolve, parse and recurse 584 // out of line module, resolve, parse and recurse
585 raw::ModuleData::Declaration { name, ast_id } => { 585 raw::ModuleData::Declaration { name, ast_id } => {
586 let ast_id = ast_id.with_file_id(self.file_id); 586 let ast_id = AstId::new(self.file_id, *ast_id);
587 match self.mod_dir.resolve_declaration( 587 match self.mod_dir.resolve_declaration(
588 self.def_collector.db, 588 self.def_collector.db,
589 self.file_id, 589 self.file_id,
@@ -671,21 +671,18 @@ where
671 } 671 }
672 672
673 fn collect_macro(&mut self, mac: &raw::MacroData) { 673 fn collect_macro(&mut self, mac: &raw::MacroData) {
674 let ast_id = AstId::new(self.file_id, mac.ast_id);
675
674 // Case 1: macro rules, define a macro in crate-global mutable scope 676 // Case 1: macro rules, define a macro in crate-global mutable scope
675 if is_macro_rules(&mac.path) { 677 if is_macro_rules(&mac.path) {
676 if let Some(name) = &mac.name { 678 if let Some(name) = &mac.name {
677 let macro_id = MacroDefId { 679 let macro_id = MacroDefId { ast_id, krate: self.def_collector.def_map.krate };
678 ast_id: mac.ast_id.with_file_id(self.file_id),
679 krate: self.def_collector.def_map.krate,
680 };
681 let macro_ = MacroDef { id: macro_id }; 680 let macro_ = MacroDef { id: macro_id };
682 self.def_collector.define_macro(self.module_id, name.clone(), macro_, mac.export); 681 self.def_collector.define_macro(self.module_id, name.clone(), macro_, mac.export);
683 } 682 }
684 return; 683 return;
685 } 684 }
686 685
687 let ast_id = mac.ast_id.with_file_id(self.file_id);
688
689 // Case 2: try to resolve in legacy scope and expand macro_rules, triggering 686 // Case 2: try to resolve in legacy scope and expand macro_rules, triggering
690 // recursive item collection. 687 // recursive item collection.
691 if let Some(macro_def) = mac.path.as_ident().and_then(|name| { 688 if let Some(macro_def) = mac.path.as_ident().and_then(|name| {