diff options
Diffstat (limited to 'crates/hir/src/semantics/source_to_def.rs')
-rw-r--r-- | crates/hir/src/semantics/source_to_def.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs index 9bf60c72a..6c612ee86 100644 --- a/crates/hir/src/semantics/source_to_def.rs +++ b/crates/hir/src/semantics/source_to_def.rs | |||
@@ -30,12 +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 | 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_def_map.module_id(local_id)) |
37 | })?; | 38 | }) |
38 | Some(ModuleId { krate, local_id }) | ||
39 | } | 39 | } |
40 | 40 | ||
41 | 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> { |
@@ -60,9 +60,9 @@ impl SourceToDefCtx<'_, '_> { | |||
60 | }?; | 60 | }?; |
61 | 61 | ||
62 | let child_name = src.value.name()?.as_name(); | 62 | let child_name = src.value.name()?.as_name(); |
63 | let def_map = self.db.crate_def_map(parent_module.krate); | 63 | let def_map = parent_module.def_map(self.db.upcast()); |
64 | 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)?; |
65 | Some(ModuleId { krate: parent_module.krate, local_id: child_id }) | 65 | Some(def_map.module_id(child_id)) |
66 | } | 66 | } |
67 | 67 | ||
68 | 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> { |
@@ -185,7 +185,7 @@ impl SourceToDefCtx<'_, '_> { | |||
185 | ) -> Option<MacroDefId> { | 185 | ) -> Option<MacroDefId> { |
186 | let kind = MacroDefKind::Declarative; | 186 | let kind = MacroDefKind::Declarative; |
187 | let file_id = src.file_id.original_file(self.db.upcast()); | 187 | let file_id = src.file_id.original_file(self.db.upcast()); |
188 | let krate = self.file_to_def(file_id)?.krate; | 188 | let krate = self.file_to_def(file_id)?.krate(); |
189 | let file_ast_id = self.db.ast_id_map(src.file_id).ast_id(&src.value); | 189 | let file_ast_id = self.db.ast_id_map(src.file_id).ast_id(&src.value); |
190 | let ast_id = Some(AstId::new(src.file_id, file_ast_id.upcast())); | 190 | let ast_id = Some(AstId::new(src.file_id, file_ast_id.upcast())); |
191 | Some(MacroDefId { krate, ast_id, kind, local_inner: false }) | 191 | Some(MacroDefId { krate, ast_id, kind, local_inner: false }) |