Skip to content

Commit b1b7077

Browse files
committed
remove ted from convert_tuple_struct_to_named_struct
Signed-off-by: Hayashi Mikihiro <[email protected]>
1 parent dfc9bd0 commit b1b7077

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use ide_db::defs::{Definition, NameRefClass};
33
use syntax::{
44
SyntaxKind, SyntaxNode,
55
ast::{self, AstNode, HasAttrs, HasGenericParams, HasVisibility},
6-
match_ast, ted,
6+
match_ast,
7+
syntax_editor::{Position, SyntaxEditor},
78
};
89

910
use crate::{AssistContext, AssistId, Assists, assist_context::SourceChangeBuilder};
@@ -93,12 +94,13 @@ fn edit_struct_def(
9394
names: Vec<ast::Name>,
9495
) {
9596
let record_fields = tuple_fields.fields().zip(names).filter_map(|(f, name)| {
96-
let field = ast::make::record_field(f.visibility(), name, f.ty()?).clone_for_update();
97-
ted::insert_all(
98-
ted::Position::first_child_of(field.syntax()),
97+
let field = ast::make::record_field(f.visibility(), name, f.ty()?);
98+
let mut editor = SyntaxEditor::new(field.syntax().clone());
99+
editor.insert_all(
100+
Position::first_child_of(field.syntax()),
99101
f.attrs().map(|attr| attr.syntax().clone_subtree().clone_for_update().into()).collect(),
100102
);
101-
Some(field)
103+
ast::RecordField::cast(editor.finish().new_root().clone())
102104
});
103105
let record_fields = ast::make::record_field_list(record_fields);
104106
let tuple_fields_text_range = tuple_fields.syntax().text_range();

0 commit comments

Comments
 (0)