From d3188769e41a051df7f02395b43f11e5cedede0b Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sat, 1 Feb 2020 22:13:02 +0200 Subject: Auto import functions --- crates/ra_hir/src/code_model.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 500b34c17..eaacf8c9e 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -119,7 +119,7 @@ impl_froms!( BuiltinType ); -pub use hir_def::{attr::Attrs, visibility::Visibility, AssocItemId}; +pub use hir_def::{attr::Attrs, item_scope::ItemInNs, visibility::Visibility, AssocItemId}; use rustc_hash::FxHashSet; impl Module { @@ -238,11 +238,16 @@ impl Module { item: ModuleDef, ) -> Option { // FIXME expose namespace choice - hir_def::find_path::find_path( - db, - hir_def::item_scope::ItemInNs::Types(item.into()), - self.into(), - ) + hir_def::find_path::find_path(db, determine_item_namespace(item), self.into()) + } +} + +fn determine_item_namespace(module_def: ModuleDef) -> ItemInNs { + match module_def { + ModuleDef::Static(_) | ModuleDef::Const(_) | ModuleDef::Function(_) => { + ItemInNs::Values(module_def.into()) + } + _ => ItemInNs::Types(module_def.into()), } } -- cgit v1.2.3