aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src/semantics
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-01-22 15:31:40 +0000
committerJonas Schievink <[email protected]>2021-01-22 15:33:58 +0000
commitce29730bc773a27eaeaae7fa4122563df3b253b6 (patch)
tree57818d6bc1e176a421f63c01a6561fb5e6a291b2 /crates/hir/src/semantics
parenta5322e3d5b813e4bce7a73762c14bebbd9a36e01 (diff)
Obtain `ModuleId`'s `DefMap` through a method
Diffstat (limited to 'crates/hir/src/semantics')
-rw-r--r--crates/hir/src/semantics/source_to_def.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs
index 9bf60c72a..775f7ec8b 100644
--- a/crates/hir/src/semantics/source_to_def.rs
+++ b/crates/hir/src/semantics/source_to_def.rs
@@ -31,6 +31,7 @@ impl SourceToDefCtx<'_, '_> {
31 pub(super) fn file_to_def(&mut self, file: FileId) -> Option<ModuleId> { 31 pub(super) fn file_to_def(&mut self, file: FileId) -> Option<ModuleId> {
32 let _p = profile::span("SourceBinder::to_module_def"); 32 let _p = profile::span("SourceBinder::to_module_def");
33 let (krate, local_id) = self.db.relevant_crates(file).iter().find_map(|&crate_id| { 33 let (krate, local_id) = self.db.relevant_crates(file).iter().find_map(|&crate_id| {
34 // FIXME: inner items
34 let crate_def_map = self.db.crate_def_map(crate_id); 35 let crate_def_map = self.db.crate_def_map(crate_id);
35 let local_id = crate_def_map.modules_for_file(file).next()?; 36 let local_id = crate_def_map.modules_for_file(file).next()?;
36 Some((crate_id, local_id)) 37 Some((crate_id, local_id))
@@ -60,7 +61,7 @@ impl SourceToDefCtx<'_, '_> {
60 }?; 61 }?;
61 62
62 let child_name = src.value.name()?.as_name(); 63 let child_name = src.value.name()?.as_name();
63 let def_map = self.db.crate_def_map(parent_module.krate); 64 let def_map = parent_module.def_map(self.db.upcast());
64 let child_id = *def_map[parent_module.local_id].children.get(&child_name)?; 65 let child_id = *def_map[parent_module.local_id].children.get(&child_name)?;
65 Some(ModuleId { krate: parent_module.krate, local_id: child_id }) 66 Some(ModuleId { krate: parent_module.krate, local_id: child_id })
66 } 67 }