]> git.lizzy.rs Git - rust.git/commitdiff
Ignore associated items during unqialified path fuzzy completions
authorKirill Bulatov <mail4score@gmail.com>
Sun, 3 Jan 2021 13:58:15 +0000 (15:58 +0200)
committerKirill Bulatov <mail4score@gmail.com>
Mon, 4 Jan 2021 15:44:27 +0000 (17:44 +0200)
crates/completion/src/completions/unqualified_path.rs

index 81a6d00e2b6551bdbbe7958bb84370fe2a8da19c..068b6b407e8efb6727e6904944233f08bee0471a 100644 (file)
@@ -3,7 +3,7 @@
 use std::iter;
 
 use either::Either;
-use hir::{Adt, ModPath, ModuleDef, ScopeDef, Type};
+use hir::{Adt, AsAssocItem, ModPath, ModuleDef, ScopeDef, Type};
 use ide_db::helpers::insert_use::ImportScope;
 use ide_db::imports_locator;
 use syntax::AstNode;
@@ -143,6 +143,14 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<()
         potential_import_name,
         true,
     )
+    .filter(|import_candidate| match import_candidate {
+        Either::Left(ModuleDef::Function(function)) => function.as_assoc_item(ctx.db).is_none(),
+        Either::Left(ModuleDef::Const(const_)) => const_.as_assoc_item(ctx.db).is_none(),
+        Either::Left(ModuleDef::TypeAlias(type_alias)) => {
+            type_alias.as_assoc_item(ctx.db).is_none()
+        }
+        _ => true,
+    })
     .filter_map(|import_candidate| {
         Some(match import_candidate {
             Either::Left(module_def) => {