diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-05-14 18:01:05 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-05-14 18:01:05 +0100 |
commit | 6c0f20d79f8e5da57bd907aa1c3324fb92344b9a (patch) | |
tree | 0abf081283df9de4bb1318396b007d8fc9f93adf /crates/syntax/src/ast/edit_in_place.rs | |
parent | a32589f773be2c19e6b6307b5302d07ec3ab6db6 (diff) | |
parent | 883dd1568f3f1824b88a136e69248c7e7d476e7e (diff) |
Merge #8838
8838: internal: use more mutable APIs r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/syntax/src/ast/edit_in_place.rs')
-rw-r--r-- | crates/syntax/src/ast/edit_in_place.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/crates/syntax/src/ast/edit_in_place.rs b/crates/syntax/src/ast/edit_in_place.rs index 9812e00c9..ca777d057 100644 --- a/crates/syntax/src/ast/edit_in_place.rs +++ b/crates/syntax/src/ast/edit_in_place.rs | |||
@@ -330,6 +330,22 @@ impl ast::AssocItemList { | |||
330 | } | 330 | } |
331 | } | 331 | } |
332 | 332 | ||
333 | impl ast::Fn { | ||
334 | pub fn get_or_create_body(&self) -> ast::BlockExpr { | ||
335 | if self.body().is_none() { | ||
336 | let body = make::ext::empty_block_expr().clone_for_update(); | ||
337 | match self.semicolon_token() { | ||
338 | Some(semi) => { | ||
339 | ted::replace(semi, body.syntax()); | ||
340 | ted::insert(Position::before(body.syntax), make::tokens::single_space()); | ||
341 | } | ||
342 | None => ted::append_child(self.syntax(), body.syntax()), | ||
343 | } | ||
344 | } | ||
345 | self.body().unwrap() | ||
346 | } | ||
347 | } | ||
348 | |||
333 | #[cfg(test)] | 349 | #[cfg(test)] |
334 | mod tests { | 350 | mod tests { |
335 | use std::fmt; | 351 | use std::fmt; |