diff options
Diffstat (limited to 'crates/ra_syntax/src/ast/edit.rs')
-rw-r--r-- | crates/ra_syntax/src/ast/edit.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 0e78d8b63..d2630e9e9 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs | |||
@@ -276,7 +276,7 @@ pub fn replace_descendants<N: AstNode, D: AstNode>( | |||
276 | .into_iter() | 276 | .into_iter() |
277 | .map(|(from, to)| (from.syntax().clone().into(), to.syntax().clone().into())) | 277 | .map(|(from, to)| (from.syntax().clone().into(), to.syntax().clone().into())) |
278 | .collect::<FxHashMap<SyntaxElement, _>>(); | 278 | .collect::<FxHashMap<SyntaxElement, _>>(); |
279 | let new_syntax = algo::replace_descendants(parent.syntax(), &|n| map.get(n).cloned()); | 279 | let new_syntax = algo::replace_descendants(parent.syntax(), |n| map.get(n).cloned()); |
280 | N::cast(new_syntax).unwrap() | 280 | N::cast(new_syntax).unwrap() |
281 | } | 281 | } |
282 | 282 | ||
@@ -331,7 +331,7 @@ impl IndentLevel { | |||
331 | ) | 331 | ) |
332 | }) | 332 | }) |
333 | .collect(); | 333 | .collect(); |
334 | algo::replace_descendants(&node, &|n| replacements.get(n).cloned()) | 334 | algo::replace_descendants(&node, |n| replacements.get(n).cloned()) |
335 | } | 335 | } |
336 | 336 | ||
337 | pub fn decrease_indent<N: AstNode>(self, node: N) -> N { | 337 | pub fn decrease_indent<N: AstNode>(self, node: N) -> N { |
@@ -359,7 +359,7 @@ impl IndentLevel { | |||
359 | ) | 359 | ) |
360 | }) | 360 | }) |
361 | .collect(); | 361 | .collect(); |
362 | algo::replace_descendants(&node, &|n| replacements.get(n).cloned()) | 362 | algo::replace_descendants(&node, |n| replacements.get(n).cloned()) |
363 | } | 363 | } |
364 | } | 364 | } |
365 | 365 | ||
@@ -389,7 +389,7 @@ fn insert_children<N: AstNode>( | |||
389 | position: InsertPosition<SyntaxElement>, | 389 | position: InsertPosition<SyntaxElement>, |
390 | to_insert: impl IntoIterator<Item = SyntaxElement>, | 390 | to_insert: impl IntoIterator<Item = SyntaxElement>, |
391 | ) -> N { | 391 | ) -> N { |
392 | let new_syntax = algo::insert_children(parent.syntax(), position, &mut to_insert.into_iter()); | 392 | let new_syntax = algo::insert_children(parent.syntax(), position, to_insert); |
393 | N::cast(new_syntax).unwrap() | 393 | N::cast(new_syntax).unwrap() |
394 | } | 394 | } |
395 | 395 | ||
@@ -404,8 +404,7 @@ fn replace_children<N: AstNode>( | |||
404 | to_replace: RangeInclusive<SyntaxElement>, | 404 | to_replace: RangeInclusive<SyntaxElement>, |
405 | to_insert: impl IntoIterator<Item = SyntaxElement>, | 405 | to_insert: impl IntoIterator<Item = SyntaxElement>, |
406 | ) -> N { | 406 | ) -> N { |
407 | let new_syntax = | 407 | let new_syntax = algo::replace_children(parent.syntax(), to_replace, to_insert); |
408 | algo::replace_children(parent.syntax(), to_replace, &mut to_insert.into_iter()); | ||
409 | N::cast(new_syntax).unwrap() | 408 | N::cast(new_syntax).unwrap() |
410 | } | 409 | } |
411 | 410 | ||