diff options
Diffstat (limited to 'crates/ra_hir/src/nameres/collector.rs')
-rw-r--r-- | crates/ra_hir/src/nameres/collector.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs index 54514becc..aa5885f04 100644 --- a/crates/ra_hir/src/nameres/collector.rs +++ b/crates/ra_hir/src/nameres/collector.rs | |||
@@ -562,9 +562,10 @@ where | |||
562 | 562 | ||
563 | fn collect_module(&mut self, module: &raw::ModuleData, attrs: &[Attr]) { | 563 | fn collect_module(&mut self, module: &raw::ModuleData, attrs: &[Attr]) { |
564 | let path_attr = self.path_attr(attrs); | 564 | let path_attr = self.path_attr(attrs); |
565 | let is_macro_use = self.is_macro_use(attrs); | ||
565 | match module { | 566 | match module { |
566 | // inline module, just recurse | 567 | // inline module, just recurse |
567 | raw::ModuleData::Definition { name, items, ast_id, is_macro_use } => { | 568 | raw::ModuleData::Definition { name, items, ast_id } => { |
568 | let module_id = | 569 | let module_id = |
569 | self.push_child_module(name.clone(), ast_id.with_file_id(self.file_id), None); | 570 | self.push_child_module(name.clone(), ast_id.with_file_id(self.file_id), None); |
570 | 571 | ||
@@ -576,12 +577,12 @@ where | |||
576 | mod_dir: self.mod_dir.descend_into_definition(name, path_attr), | 577 | mod_dir: self.mod_dir.descend_into_definition(name, path_attr), |
577 | } | 578 | } |
578 | .collect(&*items); | 579 | .collect(&*items); |
579 | if *is_macro_use { | 580 | if is_macro_use { |
580 | self.import_all_legacy_macros(module_id); | 581 | self.import_all_legacy_macros(module_id); |
581 | } | 582 | } |
582 | } | 583 | } |
583 | // out of line module, resolve, parse and recurse | 584 | // out of line module, resolve, parse and recurse |
584 | raw::ModuleData::Declaration { name, ast_id, is_macro_use } => { | 585 | raw::ModuleData::Declaration { name, ast_id } => { |
585 | let ast_id = ast_id.with_file_id(self.file_id); | 586 | let ast_id = ast_id.with_file_id(self.file_id); |
586 | match self.mod_dir.resolve_submodule( | 587 | match self.mod_dir.resolve_submodule( |
587 | self.def_collector.db, | 588 | self.def_collector.db, |
@@ -600,7 +601,7 @@ where | |||
600 | mod_dir, | 601 | mod_dir, |
601 | } | 602 | } |
602 | .collect(raw_items.items()); | 603 | .collect(raw_items.items()); |
603 | if *is_macro_use { | 604 | if is_macro_use { |
604 | self.import_all_legacy_macros(module_id); | 605 | self.import_all_legacy_macros(module_id); |
605 | } | 606 | } |
606 | } | 607 | } |
@@ -720,6 +721,10 @@ where | |||
720 | fn path_attr<'a>(&self, attrs: &'a [Attr]) -> Option<&'a SmolStr> { | 721 | fn path_attr<'a>(&self, attrs: &'a [Attr]) -> Option<&'a SmolStr> { |
721 | attrs.iter().find_map(|attr| attr.as_path()) | 722 | attrs.iter().find_map(|attr| attr.as_path()) |
722 | } | 723 | } |
724 | |||
725 | fn is_macro_use<'a>(&self, attrs: &'a [Attr]) -> bool { | ||
726 | attrs.iter().any(|attr| attr.is_simple_atom("macro_use")) | ||
727 | } | ||
723 | } | 728 | } |
724 | 729 | ||
725 | fn is_macro_rules(path: &Path) -> bool { | 730 | fn is_macro_rules(path: &Path) -> bool { |