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-07 22:25:45 +0000
committerKirill Bulatov <[email protected]>2021-03-08 21:59:20 +0000
commitdccbb38d2e28bfeb53f31c13de3b83e72f1a476c (patch)
treecf651b25be3c2dd2618e90738aa4f6600077cc9a /crates/ide_assists/src/handlers/replace_derive_with_manual_impl.rs
parentdb61d4ea13113cd6c4e0661075ea9b2f739be862 (diff)
Less lifetines: derive SemanticsScope in place
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.rs31
1 files changed, 14 insertions, 17 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 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) {