diff options
Diffstat (limited to 'crates/ide_assists/src/handlers')
-rw-r--r-- | crates/ide_assists/src/handlers/auto_import.rs | 4 | ||||
-rw-r--r-- | crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs | 31 |
2 files changed, 15 insertions, 20 deletions
diff --git a/crates/ide_assists/src/handlers/auto_import.rs b/crates/ide_assists/src/handlers/auto_import.rs index eb8d35e95..5546c3a4e 100644 --- a/crates/ide_assists/src/handlers/auto_import.rs +++ b/crates/ide_assists/src/handlers/auto_import.rs | |||
@@ -112,9 +112,7 @@ pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> | |||
112 | Some(()) | 112 | Some(()) |
113 | } | 113 | } |
114 | 114 | ||
115 | pub(super) fn find_importable_node<'a>( | 115 | pub(super) fn find_importable_node(ctx: &AssistContext) -> Option<(ImportAssets, SyntaxNode)> { |
116 | ctx: &'a AssistContext, | ||
117 | ) -> Option<(ImportAssets<'a>, SyntaxNode)> { | ||
118 | if let Some(path_under_caret) = ctx.find_node_at_offset_with_descend::<ast::Path>() { | 116 | if let Some(path_under_caret) = ctx.find_node_at_offset_with_descend::<ast::Path>() { |
119 | ImportAssets::for_exact_path(&path_under_caret, &ctx.sema) | 117 | ImportAssets::for_exact_path(&path_under_caret, &ctx.sema) |
120 | .zip(Some(path_under_caret.syntax().clone())) | 118 | .zip(Some(path_under_caret.syntax().clone())) |
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 93a03e8b2..88fe2fe90 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 | |||
@@ -65,23 +65,20 @@ 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 = items_locator::with_for_exact_name( | 68 | let found_traits = |
69 | &ctx.sema, | 69 | items_locator::with_exact_name(&ctx.sema, current_crate, trait_token.text().to_string()) |
70 | current_crate, | 70 | .into_iter() |
71 | trait_token.text().to_string(), | 71 | .filter_map(|item| match ModuleDef::from(item.as_module_def_id()?) { |
72 | ) | 72 | ModuleDef::Trait(trait_) => Some(trait_), |
73 | .into_iter() | 73 | _ => None, |
74 | .filter_map(|item| match ModuleDef::from(item.as_module_def_id()?) { | 74 | }) |
75 | ModuleDef::Trait(trait_) => Some(trait_), | 75 | .flat_map(|trait_| { |
76 | _ => None, | 76 | current_module |
77 | }) | 77 | .find_use_path(ctx.sema.db, hir::ModuleDef::Trait(trait_)) |
78 | .flat_map(|trait_| { | 78 | .as_ref() |
79 | current_module | 79 | .map(mod_path_to_ast) |
80 | .find_use_path(ctx.sema.db, hir::ModuleDef::Trait(trait_)) | 80 | .zip(Some(trait_)) |
81 | .as_ref() | 81 | }); |
82 | .map(mod_path_to_ast) | ||
83 | .zip(Some(trait_)) | ||
84 | }); | ||
85 | 82 | ||
86 | let mut no_traits_found = true; | 83 | let mut no_traits_found = true; |
87 | for (trait_path, trait_) in found_traits.inspect(|_| no_traits_found = false) { | 84 | for (trait_path, trait_) in found_traits.inspect(|_| no_traits_found = false) { |