Unnamed repository; edit this file 'description' to name the repository.
3 files changed, 18 insertions, 13 deletions
diff --git a/crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs b/crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs index 1d6450a975..0a23bd6d71 100644 --- a/crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs +++ b/crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs @@ -7,7 +7,10 @@ use syntax::{ match_ast, ted, }; -use crate::{AssistContext, AssistId, Assists, assist_context::SourceChangeBuilder, utils::find_struct_definition_from_cursor}; +use crate::{ + AssistContext, AssistId, Assists, assist_context::SourceChangeBuilder, + utils::find_struct_definition_from_cursor, +}; // Assist: convert_named_struct_to_tuple_struct // @@ -374,7 +377,6 @@ impl A { ); } - #[test] fn convert_struct_referenced_via_self_kw() { check_assist( diff --git a/crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs b/crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs index 5c2a3cdc30..464309dadb 100644 --- a/crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs +++ b/crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs @@ -6,7 +6,10 @@ use syntax::{ match_ast, ted, }; -use crate::{AssistContext, AssistId, Assists, assist_context::SourceChangeBuilder, utils::find_struct_definition_from_cursor}; +use crate::{ + AssistContext, AssistId, Assists, assist_context::SourceChangeBuilder, + utils::find_struct_definition_from_cursor, +}; // Assist: convert_tuple_struct_to_named_struct // @@ -356,7 +359,7 @@ impl A { ); } - #[test] + #[test] fn convert_simple_struct_cursor_on_visibility_keyword() { check_assist( convert_tuple_struct_to_named_struct, diff --git a/crates/ide-assists/src/utils.rs b/crates/ide-assists/src/utils.rs index 1c0e022d01..5741b15fdc 100644 --- a/crates/ide-assists/src/utils.rs +++ b/crates/ide-assists/src/utils.rs @@ -1150,22 +1150,22 @@ pub fn is_body_const(sema: &Semantics<'_, RootDatabase>, expr: &ast::Expr) -> bo } /// Gets the struct definition from a context -pub(crate) fn find_struct_definition_from_cursor(ctx: &AssistContext<'_>) --> Option<Either<ast::Struct, ast::Variant>> -{ - ctx.find_node_at_offset::<ast::Name>().and_then(|name| name.syntax().parent()) +pub(crate) fn find_struct_definition_from_cursor( + ctx: &AssistContext<'_>, +) -> Option<Either<ast::Struct, ast::Variant>> { + ctx.find_node_at_offset::<ast::Name>() + .and_then(|name| name.syntax().parent()) .or(find_struct_keyword(ctx).and_then(|kw| kw.parent())) - .or(ctx.find_node_at_offset::<ast::Visibility>().and_then(|visibility| visibility.syntax().parent())) + .or(ctx + .find_node_at_offset::<ast::Visibility>() + .and_then(|visibility| visibility.syntax().parent())) .and_then(<Either<ast::Struct, ast::Variant>>::cast) } fn find_struct_keyword(ctx: &AssistContext<'_>) -> Option<SyntaxToken> { // Attempt to find the token at the current cursor offset - ctx - .token_at_offset() - .find(|leaf| match leaf.kind() { + ctx.token_at_offset().find(|leaf| match leaf.kind() { STRUCT_KW => true, _ => false, }) } - |