From 81b0976187d73eba4f9b14d8a0b8539ab8f06dcd Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 19 Aug 2020 18:58:48 +0200 Subject: Future proof find-usages API We might want to provide more efficient impls for check if usages exist, limiting the search, filtering and cancellation, so let's violate YAGNI a bit here. --- crates/assists/src/handlers/extract_struct_from_enum_variant.rs | 2 +- crates/assists/src/handlers/inline_local_variable.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/assists/src/handlers') diff --git a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs index d62e06b4a..c1124b9e2 100644 --- a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs @@ -53,7 +53,7 @@ pub(crate) fn extract_struct_from_enum_variant( target, |builder| { let definition = Definition::ModuleDef(ModuleDef::EnumVariant(variant_hir)); - let res = definition.find_usages(&ctx.sema, None); + let res = definition.usages(&ctx.sema).all(); let start_offset = variant.parent_enum().syntax().text_range().start(); let mut visited_modules_set = FxHashSet::default(); visited_modules_set.insert(current_module); diff --git a/crates/assists/src/handlers/inline_local_variable.rs b/crates/assists/src/handlers/inline_local_variable.rs index 2b52b333b..164bbce86 100644 --- a/crates/assists/src/handlers/inline_local_variable.rs +++ b/crates/assists/src/handlers/inline_local_variable.rs @@ -44,7 +44,7 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O let def = ctx.sema.to_def(&bind_pat)?; let def = Definition::Local(def); - let refs = def.find_usages(&ctx.sema, None); + let refs = def.usages(&ctx.sema).all(); if refs.is_empty() { mark::hit!(test_not_applicable_if_variable_unused); return None; -- cgit v1.2.3