aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r--crates/ra_assists/src/handlers/move_bounds.rs23
1 files changed, 13 insertions, 10 deletions
diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs
index 342a770ec..93f26f51a 100644
--- a/crates/ra_assists/src/handlers/move_bounds.rs
+++ b/crates/ra_assists/src/handlers/move_bounds.rs
@@ -1,6 +1,6 @@
1use ra_syntax::{ 1use ra_syntax::{
2 ast::{self, edit::AstNodeEdit, make, AstNode, NameOwner, TypeBoundsOwner}, 2 ast::{self, edit::AstNodeEdit, make, AstNode, NameOwner, TypeBoundsOwner},
3 SyntaxElement, 3 match_ast,
4 SyntaxKind::*, 4 SyntaxKind::*,
5}; 5};
6 6
@@ -34,15 +34,18 @@ pub(crate) fn move_bounds_to_where_clause(ctx: AssistCtx) -> Option<Assist> {
34 return None; 34 return None;
35 } 35 }
36 36
37 let anchor: SyntaxElement = match parent.kind() { 37 let anchor = match_ast! {
38 FN_DEF => ast::FnDef::cast(parent)?.body()?.syntax().clone().into(), 38 match parent {
39 TRAIT_DEF => ast::TraitDef::cast(parent)?.item_list()?.syntax().clone().into(), 39 ast::FnDef(it) => it.body()?.syntax().clone().into(),
40 IMPL_DEF => ast::ImplDef::cast(parent)?.item_list()?.syntax().clone().into(), 40 ast::TraitDef(it) => it.item_list()?.syntax().clone().into(),
41 ENUM_DEF => ast::EnumDef::cast(parent)?.variant_list()?.syntax().clone().into(), 41 ast::ImplDef(it) => it.item_list()?.syntax().clone().into(),
42 STRUCT_DEF => parent 42 ast::EnumDef(it) => it.variant_list()?.syntax().clone().into(),
43 .children_with_tokens() 43 ast::StructDef(it) => {
44 .find(|it| it.kind() == RECORD_FIELD_DEF_LIST || it.kind() == SEMI)?, 44 it.syntax().children_with_tokens()
45 _ => return None, 45 .find(|it| it.kind() == RECORD_FIELD_DEF_LIST || it.kind() == SEMI)?
46 },
47 _ => return None
48 }
46 }; 49 };
47 50
48 ctx.add_assist(AssistId("move_bounds_to_where_clause"), "Move to where clause", |edit| { 51 ctx.add_assist(AssistId("move_bounds_to_where_clause"), "Move to where clause", |edit| {