diff options
Diffstat (limited to 'crates/ra_assists/src/assists/move_bounds.rs')
-rw-r--r-- | crates/ra_assists/src/assists/move_bounds.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/crates/ra_assists/src/assists/move_bounds.rs b/crates/ra_assists/src/assists/move_bounds.rs index fd4bdc55c..39ff51233 100644 --- a/crates/ra_assists/src/assists/move_bounds.rs +++ b/crates/ra_assists/src/assists/move_bounds.rs | |||
@@ -1,11 +1,11 @@ | |||
1 | use hir::db::HirDatabase; | 1 | use hir::db::HirDatabase; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | ast::{self, make, AstNode, NameOwner, TypeBoundsOwner}, | 3 | ast::{self, edit, make, AstNode, NameOwner, TypeBoundsOwner}, |
4 | SyntaxElement, | 4 | SyntaxElement, |
5 | SyntaxKind::*, | 5 | SyntaxKind::*, |
6 | }; | 6 | }; |
7 | 7 | ||
8 | use crate::{ast_editor::AstEditor, Assist, AssistCtx, AssistId}; | 8 | use crate::{Assist, AssistCtx, AssistId}; |
9 | 9 | ||
10 | pub(crate) fn move_bounds_to_where_clause(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 10 | pub(crate) fn move_bounds_to_where_clause(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
11 | let type_param_list = ctx.node_at_offset::<ast::TypeParamList>()?; | 11 | let type_param_list = ctx.node_at_offset::<ast::TypeParamList>()?; |
@@ -39,14 +39,12 @@ pub(crate) fn move_bounds_to_where_clause(mut ctx: AssistCtx<impl HirDatabase>) | |||
39 | .type_params() | 39 | .type_params() |
40 | .filter(|it| it.type_bound_list().is_some()) | 40 | .filter(|it| it.type_bound_list().is_some()) |
41 | .map(|type_param| { | 41 | .map(|type_param| { |
42 | let without_bounds = | 42 | let without_bounds = type_param.remove_bounds(); |
43 | AstEditor::new(type_param.clone()).remove_bounds().ast().clone(); | ||
44 | (type_param, without_bounds) | 43 | (type_param, without_bounds) |
45 | }); | 44 | }); |
46 | 45 | ||
47 | let mut ast_editor = AstEditor::new(type_param_list.clone()); | 46 | let new_type_param_list = edit::replace_descendants(&type_param_list, new_params); |
48 | ast_editor.replace_descendants(new_params); | 47 | edit.replace_ast(type_param_list.clone(), new_type_param_list); |
49 | ast_editor.into_text_edit(edit.text_edit_builder()); | ||
50 | 48 | ||
51 | let where_clause = { | 49 | let where_clause = { |
52 | let predicates = type_param_list.type_params().filter_map(build_predicate); | 50 | let predicates = type_param_list.type_params().filter_map(build_predicate); |