aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir/src/test_db.rs2
-rw-r--r--crates/ra_hir_def/src/nameres.rs6
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()