From 33c83e72b9b48177a6171fd06a26676679963a4d Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 3 Mar 2021 01:26:53 +0200 Subject: Work towards better import labels --- .../src/handlers/replace_derive_with_manual_impl.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs') 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 @@ +use hir::ModuleDef; use ide_db::helpers::mod_path_to_ast; -use ide_db::imports_locator; +use ide_db::items_locator; use itertools::Itertools; use syntax::{ ast::{self, make, AstNode, NameOwner}, @@ -64,13 +65,14 @@ pub(crate) fn replace_derive_with_manual_impl( let current_module = ctx.sema.scope(annotated_name.syntax()).module()?; let current_crate = current_module.krate(); - let found_traits = imports_locator::find_exact_imports( + let found_traits = items_locator::with_for_exact_name( &ctx.sema, current_crate, trait_token.text().to_string(), ) - .filter_map(|candidate: either::Either| match candidate { - either::Either::Left(hir::ModuleDef::Trait(trait_)) => Some(trait_), + .into_iter() + .filter_map(|item| match ModuleDef::from(item.as_module_def_id()?) { + ModuleDef::Trait(trait_) => Some(trait_), _ => None, }) .flat_map(|trait_| { -- cgit v1.2.3