diff options
Diffstat (limited to 'crates/hir/src/semantics')
-rw-r--r-- | crates/hir/src/semantics/source_to_def.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs index faede3269..6c612ee86 100644 --- a/crates/hir/src/semantics/source_to_def.rs +++ b/crates/hir/src/semantics/source_to_def.rs | |||
@@ -30,13 +30,12 @@ pub(super) struct SourceToDefCtx<'a, 'b> { | |||
30 | impl SourceToDefCtx<'_, '_> { | 30 | 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 | self.db.relevant_crates(file).iter().find_map(|&crate_id| { |
34 | // FIXME: inner items | 34 | // FIXME: inner items |
35 | let crate_def_map = self.db.crate_def_map(crate_id); | 35 | let crate_def_map = self.db.crate_def_map(crate_id); |
36 | let local_id = crate_def_map.modules_for_file(file).next()?; | 36 | let local_id = crate_def_map.modules_for_file(file).next()?; |
37 | Some((crate_id, local_id)) | 37 | Some(crate_def_map.module_id(local_id)) |
38 | })?; | 38 | }) |
39 | Some(ModuleId::top_level(krate, local_id)) | ||
40 | } | 39 | } |
41 | 40 | ||
42 | pub(super) fn module_to_def(&mut self, src: InFile<ast::Module>) -> Option<ModuleId> { | 41 | pub(super) fn module_to_def(&mut self, src: InFile<ast::Module>) -> Option<ModuleId> { |
@@ -63,8 +62,7 @@ impl SourceToDefCtx<'_, '_> { | |||
63 | let child_name = src.value.name()?.as_name(); | 62 | let child_name = src.value.name()?.as_name(); |
64 | let def_map = parent_module.def_map(self.db.upcast()); | 63 | let def_map = parent_module.def_map(self.db.upcast()); |
65 | let child_id = *def_map[parent_module.local_id].children.get(&child_name)?; | 64 | let child_id = *def_map[parent_module.local_id].children.get(&child_name)?; |
66 | // FIXME: handle block expression modules | 65 | Some(def_map.module_id(child_id)) |
67 | Some(ModuleId::top_level(parent_module.krate(), child_id)) | ||
68 | } | 66 | } |
69 | 67 | ||
70 | pub(super) fn trait_to_def(&mut self, src: InFile<ast::Trait>) -> Option<TraitId> { | 68 | pub(super) fn trait_to_def(&mut self, src: InFile<ast::Trait>) -> Option<TraitId> { |