aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_assists/src/assists/add_missing_impl_members.rs11
-rw-r--r--crates/ra_syntax/src/ast/edit.rs5
2 files changed, 11 insertions, 5 deletions
diff --git a/crates/ra_assists/src/assists/add_missing_impl_members.rs b/crates/ra_assists/src/assists/add_missing_impl_members.rs
index c2e3eb06b..6fd1c3753 100644
--- a/crates/ra_assists/src/assists/add_missing_impl_members.rs
+++ b/crates/ra_assists/src/assists/add_missing_impl_members.rs
@@ -75,10 +75,13 @@ fn add_missing_impl_members_inner(
75 75
76 ctx.add_action(AssistId(assist_id), label, |edit| { 76 ctx.add_action(AssistId(assist_id), label, |edit| {
77 let n_existing_items = impl_item_list.impl_items().count(); 77 let n_existing_items = impl_item_list.impl_items().count();
78 let items = missing_items.into_iter().map(|it| match it { 78 let items = missing_items
79 ast::ImplItem::FnDef(def) => edit::strip_attrs_and_docs(add_body(def).into()), 79 .into_iter()
80 _ => edit::strip_attrs_and_docs(it), 80 .map(|it| match it {
81 }); 81 ast::ImplItem::FnDef(def) => ast::ImplItem::FnDef(add_body(def)),
82 _ => it,
83 })
84 .map(|it| edit::strip_attrs_and_docs(&it));
82 let new_impl_item_list = impl_item_list.append_items(items); 85 let new_impl_item_list = impl_item_list.append_items(items);
83 let cursor_position = { 86 let cursor_position = {
84 let first_new_item = new_impl_item_list.impl_items().nth(n_existing_items).unwrap(); 87 let first_new_item = new_impl_item_list.impl_items().nth(n_existing_items).unwrap();
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index d0857d88b..03f3b5fbb 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -187,6 +187,7 @@ impl ast::RecordFieldList {
187} 187}
188 188
189impl ast::TypeParam { 189impl ast::TypeParam {
190 #[must_use]
190 pub fn remove_bounds(&self) -> ast::TypeParam { 191 pub fn remove_bounds(&self) -> ast::TypeParam {
191 let colon = match self.colon_token() { 192 let colon = match self.colon_token() {
192 Some(it) => it, 193 Some(it) => it,
@@ -200,7 +201,8 @@ impl ast::TypeParam {
200 } 201 }
201} 202}
202 203
203pub fn strip_attrs_and_docs<N: ast::AttrsOwner>(node: N) -> N { 204#[must_use]
205pub fn strip_attrs_and_docs<N: ast::AttrsOwner>(node: &N) -> N {
204 N::cast(strip_attrs_and_docs_inner(node.syntax().clone())).unwrap() 206 N::cast(strip_attrs_and_docs_inner(node.syntax().clone())).unwrap()
205} 207}
206 208
@@ -217,6 +219,7 @@ fn strip_attrs_and_docs_inner(mut node: SyntaxNode) -> SyntaxNode {
217 node 219 node
218} 220}
219 221
222#[must_use]
220pub fn replace_descendants<N: AstNode, D: AstNode>( 223pub fn replace_descendants<N: AstNode, D: AstNode>(
221 parent: &N, 224 parent: &N,
222 replacement_map: impl Iterator<Item = (D, D)>, 225 replacement_map: impl Iterator<Item = (D, D)>,