From a28907af8ca93077601053cf168ac2429855c394 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 15 Nov 2019 10:42:54 +0300 Subject: Privatize modules --- crates/ra_hir/src/test_db.rs | 2 +- crates/ra_hir_def/src/nameres.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'crates') 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 { let crate_graph = self.crate_graph(); for krate in crate_graph.iter().next() { let crate_def_map = self.crate_def_map(krate); - for (module_id, _) in crate_def_map.modules.iter() { + for module_id in crate_def_map.modules() { let module_id = ModuleId { krate, module_id }; let module = crate::Module::from(module_id); 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 { prelude: Option, extern_prelude: FxHashMap, root: CrateModuleId, - pub modules: Arena, + modules: Arena, /// Some macros are not well-behavior, which leads to infinite loop /// e.g. macro_rules! foo { ($ty:ty) => { foo!($ty); } } @@ -259,6 +259,10 @@ impl CrateDefMap { (res.resolved_def, res.segment_index) } + pub fn modules(&self) -> impl Iterator + '_ { + self.modules.iter().map(|(id, _data)| id) + } + pub fn modules_for_file(&self, file_id: FileId) -> impl Iterator + '_ { self.modules .iter() -- cgit v1.2.3