From 0dcec31553f0fe42d7c18e6471655e8fa2258bfc Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 1 Mar 2021 19:36:34 +0100 Subject: Fix `find_path` when inner items are present --- crates/hir_def/src/item_scope.rs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'crates/hir_def/src/item_scope.rs') diff --git a/crates/hir_def/src/item_scope.rs b/crates/hir_def/src/item_scope.rs index ee46c3330..4e5daa2ff 100644 --- a/crates/hir_def/src/item_scope.rs +++ b/crates/hir_def/src/item_scope.rs @@ -12,8 +12,8 @@ use stdx::format_to; use test_utils::mark; use crate::{ - db::DefDatabase, per_ns::PerNs, visibility::Visibility, AdtId, BuiltinType, HasModule, ImplId, - LocalModuleId, Lookup, MacroDefId, ModuleDefId, ModuleId, TraitId, + db::DefDatabase, per_ns::PerNs, visibility::Visibility, AdtId, BuiltinType, ImplId, + LocalModuleId, MacroDefId, ModuleDefId, ModuleId, TraitId, }; #[derive(Copy, Clone)] @@ -375,19 +375,9 @@ impl ItemInNs { /// Returns the crate defining this item (or `None` if `self` is built-in). pub fn krate(&self, db: &dyn DefDatabase) -> Option { - Some(match self { - ItemInNs::Types(did) | ItemInNs::Values(did) => match did { - ModuleDefId::ModuleId(id) => id.krate, - ModuleDefId::FunctionId(id) => id.lookup(db).module(db).krate, - ModuleDefId::AdtId(id) => id.module(db).krate, - ModuleDefId::EnumVariantId(id) => id.parent.lookup(db).container.module(db).krate, - ModuleDefId::ConstId(id) => id.lookup(db).container.module(db).krate, - ModuleDefId::StaticId(id) => id.lookup(db).container.module(db).krate, - ModuleDefId::TraitId(id) => id.lookup(db).container.module(db).krate, - ModuleDefId::TypeAliasId(id) => id.lookup(db).module(db).krate, - ModuleDefId::BuiltinType(_) => return None, - }, - ItemInNs::Macros(id) => return Some(id.krate), - }) + match self { + ItemInNs::Types(did) | ItemInNs::Values(did) => did.module(db).map(|m| m.krate), + ItemInNs::Macros(id) => Some(id.krate), + } } } -- cgit v1.2.3