aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2021-03-02 23:26:53 +0000
committerKirill Bulatov <[email protected]>2021-03-08 21:59:20 +0000
commit33c83e72b9b48177a6171fd06a26676679963a4d (patch)
treeb787206319b2cf0050e4ce7c89ad4365b9a43c11 /crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs
parent4d4ac1d4fa0aba107a27d3fd2d209304dfe69b9f (diff)
Work towards better import labels
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.rs10
1 files changed, 6 insertions, 4 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 c69bc5cac..93a03e8b2 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,6 @@
1use hir::ModuleDef;
1use ide_db::helpers::mod_path_to_ast; 2use ide_db::helpers::mod_path_to_ast;
2use ide_db::imports_locator; 3use ide_db::items_locator;
3use itertools::Itertools; 4use itertools::Itertools;
4use syntax::{ 5use syntax::{
5 ast::{self, make, AstNode, NameOwner}, 6 ast::{self, make, AstNode, NameOwner},
@@ -64,13 +65,14 @@ pub(crate) fn replace_derive_with_manual_impl(
64 let current_module = ctx.sema.scope(annotated_name.syntax()).module()?; 65 let current_module = ctx.sema.scope(annotated_name.syntax()).module()?;
65 let current_crate = current_module.krate(); 66 let current_crate = current_module.krate();
66 67
67 let found_traits = imports_locator::find_exact_imports( 68 let found_traits = items_locator::with_for_exact_name(
68 &ctx.sema, 69 &ctx.sema,
69 current_crate, 70 current_crate,
70 trait_token.text().to_string(), 71 trait_token.text().to_string(),
71 ) 72 )
72 .filter_map(|candidate: either::Either<hir::ModuleDef, hir::MacroDef>| match candidate { 73 .into_iter()
73 either::Either::Left(hir::ModuleDef::Trait(trait_)) => Some(trait_), 74 .filter_map(|item| match ModuleDef::from(item.as_module_def_id()?) {
75 ModuleDef::Trait(trait_) => Some(trait_),
74 _ => None, 76 _ => None,
75 }) 77 })
76 .flat_map(|trait_| { 78 .flat_map(|trait_| {