diff options
Diffstat (limited to 'crates/ra_syntax/src/ast/make.rs')
-rw-r--r-- | crates/ra_syntax/src/ast/make.rs | 5 |
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 69bacf224..4621c9888 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 | } |
247 | pub fn expr_stmt(expr: ast::Expr) -> ast::ExprStmt { | 247 | pub 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 | ||
251 | pub fn token(kind: SyntaxKind) -> SyntaxToken { | 252 | pub fn token(kind: SyntaxKind) -> SyntaxToken { |