diff options
Diffstat (limited to 'crates/hir/src/semantics/source_to_def.rs')
-rw-r--r-- | crates/hir/src/semantics/source_to_def.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs index 775f7ec8b..faede3269 100644 --- a/crates/hir/src/semantics/source_to_def.rs +++ b/crates/hir/src/semantics/source_to_def.rs | |||
@@ -36,7 +36,7 @@ impl SourceToDefCtx<'_, '_> { | |||
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_id, local_id)) |
38 | })?; | 38 | })?; |
39 | Some(ModuleId { krate, local_id }) | 39 | Some(ModuleId::top_level(krate, local_id)) |
40 | } | 40 | } |
41 | 41 | ||
42 | pub(super) fn module_to_def(&mut self, src: InFile<ast::Module>) -> Option<ModuleId> { | 42 | pub(super) fn module_to_def(&mut self, src: InFile<ast::Module>) -> Option<ModuleId> { |
@@ -63,7 +63,8 @@ impl SourceToDefCtx<'_, '_> { | |||
63 | let child_name = src.value.name()?.as_name(); | 63 | let child_name = src.value.name()?.as_name(); |
64 | let def_map = parent_module.def_map(self.db.upcast()); | 64 | let def_map = parent_module.def_map(self.db.upcast()); |
65 | 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)?; |
66 | Some(ModuleId { krate: parent_module.krate, local_id: child_id }) | 66 | // FIXME: handle block expression modules |
67 | Some(ModuleId::top_level(parent_module.krate(), child_id)) | ||
67 | } | 68 | } |
68 | 69 | ||
69 | pub(super) fn trait_to_def(&mut self, src: InFile<ast::Trait>) -> Option<TraitId> { | 70 | pub(super) fn trait_to_def(&mut self, src: InFile<ast::Trait>) -> Option<TraitId> { |
@@ -186,7 +187,7 @@ impl SourceToDefCtx<'_, '_> { | |||
186 | ) -> Option<MacroDefId> { | 187 | ) -> Option<MacroDefId> { |
187 | let kind = MacroDefKind::Declarative; | 188 | let kind = MacroDefKind::Declarative; |
188 | let file_id = src.file_id.original_file(self.db.upcast()); | 189 | let file_id = src.file_id.original_file(self.db.upcast()); |
189 | let krate = self.file_to_def(file_id)?.krate; | 190 | let krate = self.file_to_def(file_id)?.krate(); |
190 | let file_ast_id = self.db.ast_id_map(src.file_id).ast_id(&src.value); | 191 | let file_ast_id = self.db.ast_id_map(src.file_id).ast_id(&src.value); |
191 | let ast_id = Some(AstId::new(src.file_id, file_ast_id.upcast())); | 192 | let ast_id = Some(AstId::new(src.file_id, file_ast_id.upcast())); |
192 | Some(MacroDefId { krate, ast_id, kind, local_inner: false }) | 193 | Some(MacroDefId { krate, ast_id, kind, local_inner: false }) |