Skip to content

Commit 070a5f8

Browse files
committed
Replace make with SyntaxFactory in convert_named_struct_to_tuple_struct
1 parent 2227bd6 commit 070a5f8

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,21 +99,20 @@ fn edit_struct_def(
9999
) {
100100
// Note that we don't need to consider macro files in this function because this is
101101
// currently not triggered for struct definitions inside macro calls.
102+
let editor = builder.make_editor(strukt.syntax());
103+
let make = editor.make();
104+
102105
let tuple_fields = record_fields.fields().filter_map(|f| {
103-
let (editor, field) =
104-
SyntaxEditor::with_ast_node(&ast::make::tuple_field(f.visibility(), f.ty()?));
105-
editor.insert_all(
106+
let (field_editor, field) =
107+
SyntaxEditor::with_ast_node(&make.tuple_field(f.visibility(), f.ty()?));
108+
field_editor.insert_all(
106109
Position::first_child_of(field.syntax()),
107110
f.attrs().map(|attr| attr.syntax().clone().into()).collect(),
108111
);
109-
let field_syntax = editor.finish().new_root().clone();
110-
let field = ast::TupleField::cast(field_syntax)?;
111-
Some(field)
112+
let field_syntax = field_editor.finish().new_root().clone();
113+
ast::TupleField::cast(field_syntax)
112114
});
113115

114-
let editor = builder.make_editor(strukt.syntax());
115-
let make = editor.make();
116-
117116
let tuple_fields = make.tuple_field_list(tuple_fields);
118117

119118
let mut elements = vec![tuple_fields.syntax().clone().into()];

0 commit comments

Comments
 (0)