diff options
author | Aleksey Kladov <[email protected]> | 2019-11-15 07:42:54 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-15 07:42:54 +0000 |
commit | a28907af8ca93077601053cf168ac2429855c394 (patch) | |
tree | e4930115d3f0249ea3f6f899a9b10b2a62a12bef | |
parent | 9c7a2aef30cb35347af646dea5a5611af1224676 (diff) |
Privatize modules
-rw-r--r-- | crates/ra_hir/src/test_db.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres.rs | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/crates/ra_hir/src/test_db.rs b/crates/ra_hir/src/test_db.rs index 5237b303a..1caa2e875 100644 --- a/crates/ra_hir/src/test_db.rs +++ b/crates/ra_hir/src/test_db.rs | |||
@@ -81,7 +81,7 @@ impl TestDB { | |||
81 | let crate_graph = self.crate_graph(); | 81 | let crate_graph = self.crate_graph(); |
82 | for krate in crate_graph.iter().next() { | 82 | for krate in crate_graph.iter().next() { |
83 | let crate_def_map = self.crate_def_map(krate); | 83 | let crate_def_map = self.crate_def_map(krate); |
84 | for (module_id, _) in crate_def_map.modules.iter() { | 84 | for module_id in crate_def_map.modules() { |
85 | let module_id = ModuleId { krate, module_id }; | 85 | let module_id = ModuleId { krate, module_id }; |
86 | let module = crate::Module::from(module_id); | 86 | let module = crate::Module::from(module_id); |
87 | module.diagnostics( | 87 | module.diagnostics( |
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index 1331fbe30..5fc592150 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs | |||
@@ -87,7 +87,7 @@ pub struct CrateDefMap { | |||
87 | prelude: Option<ModuleId>, | 87 | prelude: Option<ModuleId>, |
88 | extern_prelude: FxHashMap<Name, ModuleDefId>, | 88 | extern_prelude: FxHashMap<Name, ModuleDefId>, |
89 | root: CrateModuleId, | 89 | root: CrateModuleId, |
90 | pub modules: Arena<CrateModuleId, ModuleData>, | 90 | modules: Arena<CrateModuleId, ModuleData>, |
91 | 91 | ||
92 | /// Some macros are not well-behavior, which leads to infinite loop | 92 | /// Some macros are not well-behavior, which leads to infinite loop |
93 | /// e.g. macro_rules! foo { ($ty:ty) => { foo!($ty); } } | 93 | /// e.g. macro_rules! foo { ($ty:ty) => { foo!($ty); } } |
@@ -259,6 +259,10 @@ impl CrateDefMap { | |||
259 | (res.resolved_def, res.segment_index) | 259 | (res.resolved_def, res.segment_index) |
260 | } | 260 | } |
261 | 261 | ||
262 | pub fn modules(&self) -> impl Iterator<Item = CrateModuleId> + '_ { | ||
263 | self.modules.iter().map(|(id, _data)| id) | ||
264 | } | ||
265 | |||
262 | pub fn modules_for_file(&self, file_id: FileId) -> impl Iterator<Item = CrateModuleId> + '_ { | 266 | pub fn modules_for_file(&self, file_id: FileId) -> impl Iterator<Item = CrateModuleId> + '_ { |
263 | self.modules | 267 | self.modules |
264 | .iter() | 268 | .iter() |