aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast/make.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-03-27 11:12:17 +0000
committerAleksey Kladov <[email protected]>2020-03-27 11:15:46 +0000
commit91e482b46d43a24cd0a48ea1119b93105140cff2 (patch)
tree3fd91a247ca1a9297884139d135aca4763d02da8 /crates/ra_syntax/src/ast/make.rs
parentcbb53cf55ca350bbcada5fc759b0119d932e879d (diff)
Replace if with if-let
Diffstat (limited to 'crates/ra_syntax/src/ast/make.rs')
-rw-r--r--crates/ra_syntax/src/ast/make.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 6aee39203..c818bba55 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -127,7 +127,7 @@ pub fn condition(expr: ast::Expr, pattern: Option<ast::Pat>) -> ast::Condition {
127 match pattern { 127 match pattern {
128 None => ast_from_text(&format!("const _: () = while {} {{}};", expr)), 128 None => ast_from_text(&format!("const _: () = while {} {{}};", expr)),
129 Some(pattern) => { 129 Some(pattern) => {
130 ast_from_text(&format!("const _: () = while {} = {} {{}};", pattern, expr)) 130 ast_from_text(&format!("const _: () = while let {} = {} {{}};", pattern, expr))
131 } 131 }
132 } 132 }
133} 133}
@@ -245,7 +245,8 @@ pub fn let_stmt(pattern: ast::Pat, initializer: Option<ast::Expr>) -> ast::LetSt
245 ast_from_text(&format!("fn f() {{ {} }}", text)) 245 ast_from_text(&format!("fn f() {{ {} }}", text))
246} 246}
247pub fn expr_stmt(expr: ast::Expr) -> ast::ExprStmt { 247pub fn expr_stmt(expr: ast::Expr) -> ast::ExprStmt {
248 ast_from_text(&format!("fn f() {{ {}; }}", expr)) 248 let semi = if expr.is_block_like() { "" } else { ";" };
249 ast_from_text(&format!("fn f() {{ {}{} (); }}", expr, semi))
249} 250}
250 251
251pub fn token(kind: SyntaxKind) -> SyntaxToken { 252pub fn token(kind: SyntaxKind) -> SyntaxToken {