From 4f018d84a994e05ad8dd6f2a9445bba2126ca059 Mon Sep 17 00:00:00 2001 From: BazookaMusic Date: Sun, 1 Jun 2025 01:20:45 +0200 Subject: clippy and more formatting --- src/tools/rust-analyzer/crates/ide-assists/src/utils.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/utils.rs b/src/tools/rust-analyzer/crates/ide-assists/src/utils.rs index 676937c8168..c7a6c2d5326 100644 --- a/src/tools/rust-analyzer/crates/ide-assists/src/utils.rs +++ b/src/tools/rust-analyzer/crates/ide-assists/src/utils.rs @@ -1155,17 +1155,12 @@ pub(crate) fn get_struct_definition_from_context( ) -> Option> { ctx.find_node_at_offset::() .and_then(|name| name.syntax().parent()) - .or(find_struct_keyword(ctx).and_then(|kw| kw.parent())) + .or(ctx + .token_at_offset() + .find(|leaf| matches!(leaf.kind(), STRUCT_KW)) + .and_then(|kw| kw.parent())) .or(ctx .find_node_at_offset::() .and_then(|visibility| visibility.syntax().parent())) .and_then(>::cast) } - -fn find_struct_keyword(ctx: &AssistContext<'_>) -> Option { - // Attempt to find the token at the current cursor offset - ctx.token_at_offset().find(|leaf| match leaf.kind() { - STRUCT_KW => true, - _ => false, - }) -} -- cgit 1.4.1-3-g733a5