Skip to content

Commit 01837bc

Browse files
committed
Formatting issues resolved
1 parent a241d8e commit 01837bc

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ use syntax::{
77
match_ast, ted,
88
};
99

10-
use crate::{AssistContext, AssistId, Assists, assist_context::SourceChangeBuilder, utils::find_struct_definition_from_cursor};
10+
use crate::{
11+
AssistContext, AssistId, Assists, assist_context::SourceChangeBuilder,
12+
utils::find_struct_definition_from_cursor,
13+
};
1114

1215
// Assist: convert_named_struct_to_tuple_struct
1316
//
@@ -374,7 +377,6 @@ impl A {
374377
);
375378
}
376379

377-
378380
#[test]
379381
fn convert_struct_referenced_via_self_kw() {
380382
check_assist(

src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ use syntax::{
66
match_ast, ted,
77
};
88

9-
use crate::{AssistContext, AssistId, Assists, assist_context::SourceChangeBuilder, utils::find_struct_definition_from_cursor};
9+
use crate::{
10+
AssistContext, AssistId, Assists, assist_context::SourceChangeBuilder,
11+
utils::find_struct_definition_from_cursor,
12+
};
1013

1114
// Assist: convert_tuple_struct_to_named_struct
1215
//
@@ -356,7 +359,7 @@ impl A {
356359
);
357360
}
358361

359-
#[test]
362+
#[test]
360363
fn convert_simple_struct_cursor_on_visibility_keyword() {
361364
check_assist(
362365
convert_tuple_struct_to_named_struct,

src/tools/rust-analyzer/crates/ide-assists/src/utils.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,22 +1150,22 @@ pub fn is_body_const(sema: &Semantics<'_, RootDatabase>, expr: &ast::Expr) -> bo
11501150
}
11511151

11521152
/// Gets the struct definition from a context
1153-
pub(crate) fn find_struct_definition_from_cursor(ctx: &AssistContext<'_>)
1154-
-> Option<Either<ast::Struct, ast::Variant>>
1155-
{
1156-
ctx.find_node_at_offset::<ast::Name>().and_then(|name| name.syntax().parent())
1153+
pub(crate) fn find_struct_definition_from_cursor(
1154+
ctx: &AssistContext<'_>,
1155+
) -> Option<Either<ast::Struct, ast::Variant>> {
1156+
ctx.find_node_at_offset::<ast::Name>()
1157+
.and_then(|name| name.syntax().parent())
11571158
.or(find_struct_keyword(ctx).and_then(|kw| kw.parent()))
1158-
.or(ctx.find_node_at_offset::<ast::Visibility>().and_then(|visibility| visibility.syntax().parent()))
1159+
.or(ctx
1160+
.find_node_at_offset::<ast::Visibility>()
1161+
.and_then(|visibility| visibility.syntax().parent()))
11591162
.and_then(<Either<ast::Struct, ast::Variant>>::cast)
11601163
}
11611164

11621165
fn find_struct_keyword(ctx: &AssistContext<'_>) -> Option<SyntaxToken> {
11631166
// Attempt to find the token at the current cursor offset
1164-
ctx
1165-
.token_at_offset()
1166-
.find(|leaf| match leaf.kind() {
1167+
ctx.token_at_offset().find(|leaf| match leaf.kind() {
11671168
STRUCT_KW => true,
11681169
_ => false,
11691170
})
11701171
}
1171-

0 commit comments

Comments
 (0)