Skip to content

Commit 3faa0e1

Browse files
committed
remove make from replace_named_generics_with_impl
1 parent 65c3f98 commit 3faa0e1

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ use ide_db::{
55
defs::Definition,
66
search::{SearchScope, UsageSearchResult},
77
};
8+
use syntax::ast::syntax_factory::SyntaxFactory;
89
use syntax::{
910
AstNode,
10-
ast::{self, HasGenericParams, HasName, HasTypeBounds, Name, NameLike, PathType, make},
11+
ast::{self, HasGenericParams, HasName, HasTypeBounds, Name, NameLike, PathType},
1112
match_ast,
1213
};
1314

@@ -72,6 +73,7 @@ pub(crate) fn replace_named_generic_with_impl(
7273
target,
7374
|edit| {
7475
let mut editor = edit.make_editor(type_param.syntax());
76+
let make = SyntaxFactory::without_mappings();
7577

7678
// remove trait from generic param list
7779
if let Some(generic_params) = fn_.generic_param_list() {
@@ -83,17 +85,14 @@ pub(crate) fn replace_named_generic_with_impl(
8385
if params.is_empty() {
8486
editor.delete(generic_params.syntax());
8587
} else {
86-
let new_generic_param_list = make::generic_param_list(params);
87-
editor.replace(
88-
generic_params.syntax(),
89-
new_generic_param_list.syntax().clone_for_update(),
90-
);
88+
let new_generic_param_list = make.generic_param_list(params);
89+
editor.replace(generic_params.syntax(), new_generic_param_list.syntax());
9190
}
9291
}
9392

94-
let new_bounds = make::impl_trait_type(type_bound_list);
93+
let new_bounds = make.impl_trait_type(type_bound_list);
9594
for path_type in path_types_to_replace.iter().rev() {
96-
editor.replace(path_type.syntax(), new_bounds.clone_for_update().syntax());
95+
editor.replace(path_type.syntax(), new_bounds.syntax());
9796
}
9897
edit.add_file_edits(ctx.vfs_file_id(), editor);
9998
},

crates/syntax/src/ast/syntax_factory/constructors.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ impl SyntaxFactory {
141141
make::where_clause(predicates).clone_for_update()
142142
}
143143

144+
pub fn impl_trait_type(&self, bounds: ast::TypeBoundList) -> ast::ImplTraitType {
145+
make::impl_trait_type(bounds).clone_for_update()
146+
}
147+
144148
pub fn expr_field(&self, receiver: ast::Expr, field: &str) -> ast::FieldExpr {
145149
let ast::Expr::FieldExpr(ast) =
146150
make::expr_field(receiver.clone(), field).clone_for_update()

0 commit comments

Comments
 (0)