aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/nameres
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-24 12:28:45 +0000
committerAleksey Kladov <[email protected]>2019-11-24 12:28:45 +0000
commit8e36cb586038e2c12e6eceae57f7a95684fc6c6d (patch)
tree178c95a19df6a463e0db472b51123355f794ad90 /crates/ra_hir_def/src/nameres
parent151180057b0304ee4dee75401e8f1aaa7aaaec21 (diff)
Simplify
Diffstat (limited to 'crates/ra_hir_def/src/nameres')
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 7b2487999..15941a1cb 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -7,7 +7,7 @@ use hir_expand::{
7}; 7};
8use ra_cfg::CfgOptions; 8use ra_cfg::CfgOptions;
9use ra_db::{CrateId, FileId}; 9use ra_db::{CrateId, FileId};
10use ra_syntax::{ast, SmolStr}; 10use ra_syntax::ast;
11use rustc_hash::{FxHashMap, FxHashSet}; 11use rustc_hash::{FxHashMap, FxHashSet};
12use test_utils::tested_by; 12use test_utils::tested_by;
13 13
@@ -599,7 +599,7 @@ where
599 } 599 }
600 600
601 fn collect_module(&mut self, module: &raw::ModuleData, attrs: &Attrs) { 601 fn collect_module(&mut self, module: &raw::ModuleData, attrs: &Attrs) {
602 let path_attr = self.path_attr(attrs); 602 let path_attr = attrs.find_string_value("path");
603 let is_macro_use = attrs.has_atom("macro_use"); 603 let is_macro_use = attrs.has_atom("macro_use");
604 match module { 604 match module {
605 // inline module, just recurse 605 // inline module, just recurse
@@ -612,7 +612,7 @@ where
612 module_id, 612 module_id,
613 file_id: self.file_id, 613 file_id: self.file_id,
614 raw_items: self.raw_items, 614 raw_items: self.raw_items,
615 mod_dir: self.mod_dir.descend_into_definition(name, path_attr), 615 mod_dir: self.mod_dir.descend_into_definition(name, path_attr.as_ref()),
616 } 616 }
617 .collect(&*items); 617 .collect(&*items);
618 if is_macro_use { 618 if is_macro_use {
@@ -626,7 +626,7 @@ where
626 self.def_collector.db, 626 self.def_collector.db,
627 self.file_id, 627 self.file_id,
628 name, 628 name,
629 path_attr, 629 path_attr.as_ref(),
630 ) { 630 ) {
631 Ok((file_id, mod_dir)) => { 631 Ok((file_id, mod_dir)) => {
632 let module_id = self.push_child_module(name.clone(), ast_id, Some(file_id)); 632 let module_id = self.push_child_module(name.clone(), ast_id, Some(file_id));
@@ -798,10 +798,6 @@ where
798 fn is_cfg_enabled(&self, attrs: &Attrs) -> bool { 798 fn is_cfg_enabled(&self, attrs: &Attrs) -> bool {
799 attrs.iter().all(|attr| attr.is_cfg_enabled(&self.def_collector.cfg_options) != Some(false)) 799 attrs.iter().all(|attr| attr.is_cfg_enabled(&self.def_collector.cfg_options) != Some(false))
800 } 800 }
801
802 fn path_attr<'a>(&self, attrs: &'a Attrs) -> Option<&'a SmolStr> {
803 attrs.iter().find_map(|attr| attr.as_path())
804 }
805} 801}
806 802
807fn is_macro_rules(path: &Path) -> bool { 803fn is_macro_rules(path: &Path) -> bool {