aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-02 10:38:03 +0000
committerGitHub <[email protected]>2020-02-02 10:38:03 +0000
commitdce7dc44be948bb6b73b79ce284ec2eb83811ae8 (patch)
tree4e223570d7ed75e24156d5452ac79ef1f1c53bf4 /crates/ra_hir/src
parent96bd4f5704f447800067ce69d50ab8b4b2315fdb (diff)
parentd3188769e41a051df7f02395b43f11e5cedede0b (diff)
Merge #2978
2978: Auto import functions r=flodiebold a=SomeoneToIgnore A follow up for https://github.com/rust-analyzer/rust-analyzer/pull/2887#issuecomment-577832601 I've used the logic for conversion from the https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_hir_def/src/item_scope.rs#L169 method. I'm not fond of how the conversion is implemented and for my needs, I can simply replace the `hir_def::item_scope::ItemInNs::Types(item.into())` with `hir_def::item_scope::ItemInNs::Values(item.into())` and it will work, so I can use this approach instead, if you find it a better one. Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/code_model.rs17
1 files changed, 11 insertions, 6 deletions
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!(
119 BuiltinType 119 BuiltinType
120); 120);
121 121
122pub use hir_def::{attr::Attrs, visibility::Visibility, AssocItemId}; 122pub use hir_def::{attr::Attrs, item_scope::ItemInNs, visibility::Visibility, AssocItemId};
123use rustc_hash::FxHashSet; 123use rustc_hash::FxHashSet;
124 124
125impl Module { 125impl Module {
@@ -238,11 +238,16 @@ impl Module {
238 item: ModuleDef, 238 item: ModuleDef,
239 ) -> Option<hir_def::path::ModPath> { 239 ) -> Option<hir_def::path::ModPath> {
240 // FIXME expose namespace choice 240 // FIXME expose namespace choice
241 hir_def::find_path::find_path( 241 hir_def::find_path::find_path(db, determine_item_namespace(item), self.into())
242 db, 242 }
243 hir_def::item_scope::ItemInNs::Types(item.into()), 243}
244 self.into(), 244
245 ) 245fn determine_item_namespace(module_def: ModuleDef) -> ItemInNs {
246 match module_def {
247 ModuleDef::Static(_) | ModuleDef::Const(_) | ModuleDef::Function(_) => {
248 ItemInNs::Values(module_def.into())
249 }
250 _ => ItemInNs::Types(module_def.into()),
246 } 251 }
247} 252}
248 253