aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax/src/ast/edit_in_place.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-05-14 18:01:05 +0100
committerGitHub <[email protected]>2021-05-14 18:01:05 +0100
commit6c0f20d79f8e5da57bd907aa1c3324fb92344b9a (patch)
tree0abf081283df9de4bb1318396b007d8fc9f93adf /crates/syntax/src/ast/edit_in_place.rs
parenta32589f773be2c19e6b6307b5302d07ec3ab6db6 (diff)
parent883dd1568f3f1824b88a136e69248c7e7d476e7e (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.rs16
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
333impl 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)]
334mod tests { 350mod tests {
335 use std::fmt; 351 use std::fmt;