File tree Expand file tree Collapse file tree 1 file changed +4
-9
lines changed
src/tools/rust-analyzer/crates/ide-assists/src Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -1155,17 +1155,12 @@ pub(crate) fn get_struct_definition_from_context(
1155
1155
) -> Option < Either < ast:: Struct , ast:: Variant > > {
1156
1156
ctx. find_node_at_offset :: < ast:: Name > ( )
1157
1157
. and_then ( |name| name. syntax ( ) . parent ( ) )
1158
- . or ( find_struct_keyword ( ctx) . and_then ( |kw| kw. parent ( ) ) )
1158
+ . or ( ctx
1159
+ . token_at_offset ( )
1160
+ . find ( |leaf| matches ! ( leaf. kind( ) , STRUCT_KW ) )
1161
+ . and_then ( |kw| kw. parent ( ) ) )
1159
1162
. or ( ctx
1160
1163
. find_node_at_offset :: < ast:: Visibility > ( )
1161
1164
. and_then ( |visibility| visibility. syntax ( ) . parent ( ) ) )
1162
1165
. and_then ( <Either < ast:: Struct , ast:: Variant > >:: cast)
1163
1166
}
1164
-
1165
- fn find_struct_keyword ( ctx : & AssistContext < ' _ > ) -> Option < SyntaxToken > {
1166
- // Attempt to find the token at the current cursor offset
1167
- ctx. token_at_offset ( ) . find ( |leaf| match leaf. kind ( ) {
1168
- STRUCT_KW => true ,
1169
- _ => false ,
1170
- } )
1171
- }
You can’t perform that action at this time.
0 commit comments