aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-20 15:55:38 +0000
committerAleksey Kladov <[email protected]>2019-12-20 15:55:38 +0000
commitaf42cb5981a1f94116b1da8cfeedb6efdd5aeb01 (patch)
tree26c26735a3c535ad78264f2c1234434ca477fc85 /crates/ra_hir_def/src
parent7adb53319d963d0a40906a6847124974da1d5183 (diff)
Privitize impls
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r--crates/ra_hir_def/src/child_by_source.rs6
-rw-r--r--crates/ra_hir_def/src/item_scope.rs6
-rw-r--r--crates/ra_hir_def/src/lang_item.rs2
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs4
4 files changed, 12 insertions, 6 deletions
diff --git a/crates/ra_hir_def/src/child_by_source.rs b/crates/ra_hir_def/src/child_by_source.rs
index 403ba8b57..4488e8502 100644
--- a/crates/ra_hir_def/src/child_by_source.rs
+++ b/crates/ra_hir_def/src/child_by_source.rs
@@ -80,9 +80,9 @@ impl ChildBySource for ModuleId {
80 80
81 module_data.scope.declarations().for_each(|item| add_module_def(db, &mut res, item)); 81 module_data.scope.declarations().for_each(|item| add_module_def(db, &mut res, item));
82 82
83 for &impl_ in module_data.scope.impls.iter() { 83 for imp in module_data.scope.impls() {
84 let src = impl_.lookup(db).source(db); 84 let src = imp.lookup(db).source(db);
85 res[keys::IMPL].insert(src, impl_) 85 res[keys::IMPL].insert(src, imp)
86 } 86 }
87 87
88 res 88 res
diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs
index ac56986cd..f51e97ef9 100644
--- a/crates/ra_hir_def/src/item_scope.rs
+++ b/crates/ra_hir_def/src/item_scope.rs
@@ -10,7 +10,7 @@ use crate::{per_ns::PerNs, BuiltinType, ImplId, LocalImportId, MacroDefId, Modul
10#[derive(Debug, Default, PartialEq, Eq)] 10#[derive(Debug, Default, PartialEq, Eq)]
11pub struct ItemScope { 11pub struct ItemScope {
12 items: FxHashMap<Name, Resolution>, 12 items: FxHashMap<Name, Resolution>,
13 pub(crate) impls: Vec<ImplId>, 13 impls: Vec<ImplId>,
14 /// Macros visible in current module in legacy textual scope 14 /// Macros visible in current module in legacy textual scope
15 /// 15 ///
16 /// For macros invoked by an unqualified identifier like `bar!()`, `legacy_macros` will be searched in first. 16 /// For macros invoked by an unqualified identifier like `bar!()`, `legacy_macros` will be searched in first.
@@ -104,6 +104,10 @@ impl ItemScope {
104 self.legacy_macros.get(name).copied() 104 self.legacy_macros.get(name).copied()
105 } 105 }
106 106
107 pub(crate) fn define_impl(&mut self, imp: ImplId) {
108 self.impls.push(imp)
109 }
110
107 pub(crate) fn push_res( 111 pub(crate) fn push_res(
108 &mut self, 112 &mut self,
109 name: Name, 113 name: Name,
diff --git a/crates/ra_hir_def/src/lang_item.rs b/crates/ra_hir_def/src/lang_item.rs
index 61b248815..cef061837 100644
--- a/crates/ra_hir_def/src/lang_item.rs
+++ b/crates/ra_hir_def/src/lang_item.rs
@@ -81,7 +81,7 @@ impl LangItems {
81 // Look for impl targets 81 // Look for impl targets
82 let def_map = db.crate_def_map(module.krate); 82 let def_map = db.crate_def_map(module.krate);
83 let module_data = &def_map[module.local_id]; 83 let module_data = &def_map[module.local_id];
84 for &impl_block in module_data.scope.impls.iter() { 84 for impl_block in module_data.scope.impls() {
85 self.collect_lang_item(db, impl_block, LangItemTarget::ImplBlockId) 85 self.collect_lang_item(db, impl_block, LangItemTarget::ImplBlockId)
86 } 86 }
87 87
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index d62fae8a6..b064ccc9c 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -635,7 +635,9 @@ where
635 let impl_id = 635 let impl_id =
636 ImplLoc { container, ast_id: AstId::new(self.file_id, ast_id) } 636 ImplLoc { container, ast_id: AstId::new(self.file_id, ast_id) }
637 .intern(self.def_collector.db); 637 .intern(self.def_collector.db);
638 self.def_collector.def_map.modules[self.module_id].scope.impls.push(impl_id) 638 self.def_collector.def_map.modules[self.module_id]
639 .scope
640 .define_impl(impl_id)
639 } 641 }
640 } 642 }
641 } 643 }