aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-03-21 09:37:08 +0000
committerGitHub <[email protected]>2021-03-21 09:37:08 +0000
commit09412d85fc3137d6ada3b27170e14c287f1a1191 (patch)
treeac01ec54df0cebba975c82008482319820ce8757 /crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs
parent2280f62a40f31d83fd79b62c46dd3d610354d78c (diff)
parent56a7d246d59d9429304b82bce2f1e71b632c5737 (diff)
Merge #8123
8123: Do not display unqualified assoc item completions r=SomeoneToIgnore a=SomeoneToIgnore Part of https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/autoimport.20weirdness Removes all flyimport completions for any unqualified associated type, effectively reverting https://github.com/rust-analyzer/rust-analyzer/pull/8095 I've explained the reasoning in the corresponding FIXME and open to discussions. As an alternative way, we could add yet another parameter in the method that's used by the `qualify_path` and enable it for the qualify assists only. Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs')
-rw-r--r--crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs35
1 files changed, 20 insertions, 15 deletions
diff --git a/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs b/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs
index 88fe2fe90..2608b56da 100644
--- a/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs
+++ b/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs
@@ -1,5 +1,5 @@
1use hir::ModuleDef; 1use hir::ModuleDef;
2use ide_db::helpers::mod_path_to_ast; 2use ide_db::helpers::{import_assets::NameToImport, mod_path_to_ast};
3use ide_db::items_locator; 3use ide_db::items_locator;
4use itertools::Itertools; 4use itertools::Itertools;
5use syntax::{ 5use syntax::{
@@ -65,20 +65,25 @@ pub(crate) fn replace_derive_with_manual_impl(
65 let current_module = ctx.sema.scope(annotated_name.syntax()).module()?; 65 let current_module = ctx.sema.scope(annotated_name.syntax()).module()?;
66 let current_crate = current_module.krate(); 66 let current_crate = current_module.krate();
67 67
68 let found_traits = 68 let found_traits = items_locator::items_with_name(
69 items_locator::with_exact_name(&ctx.sema, current_crate, trait_token.text().to_string()) 69 &ctx.sema,
70 .into_iter() 70 current_crate,
71 .filter_map(|item| match ModuleDef::from(item.as_module_def_id()?) { 71 NameToImport::Exact(trait_token.text().to_string()),
72 ModuleDef::Trait(trait_) => Some(trait_), 72 items_locator::AssocItemSearch::Exclude,
73 _ => None, 73 Some(items_locator::DEFAULT_QUERY_SEARCH_LIMIT),
74 }) 74 )
75 .flat_map(|trait_| { 75 .into_iter()
76 current_module 76 .filter_map(|item| match ModuleDef::from(item.as_module_def_id()?) {
77 .find_use_path(ctx.sema.db, hir::ModuleDef::Trait(trait_)) 77 ModuleDef::Trait(trait_) => Some(trait_),
78 .as_ref() 78 _ => None,
79 .map(mod_path_to_ast) 79 })
80 .zip(Some(trait_)) 80 .flat_map(|trait_| {
81 }); 81 current_module
82 .find_use_path(ctx.sema.db, hir::ModuleDef::Trait(trait_))
83 .as_ref()
84 .map(mod_path_to_ast)
85 .zip(Some(trait_))
86 });
82 87
83 let mut no_traits_found = true; 88 let mut no_traits_found = true;
84 for (trait_path, trait_) in found_traits.inspect(|_| no_traits_found = false) { 89 for (trait_path, trait_) in found_traits.inspect(|_| no_traits_found = false) {