Fixed statement bodies
This commit is contained in:
@@ -103,7 +103,7 @@ impl GenRust for Expression {
|
||||
if ensure_semicolon {
|
||||
ctx.expr_ensure_semicolon = true;
|
||||
|
||||
if !self.is_soft_return() {
|
||||
if !self.is_block() {
|
||||
cg.add(";");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,10 +95,14 @@ impl RustCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ensure_brackets_body(&mut self, ctx: &mut Context, expr: &StatementBody) {
|
||||
match expr {
|
||||
StatementBody::Statement(expr) => self.ensure_brackets_expr(ctx, expr),
|
||||
pub fn ensure_brackets_body(&mut self, ctx: &mut Context, body: &StatementBody) {
|
||||
match body {
|
||||
StatementBody::Expression(expr) => self.ensure_brackets_expr(ctx, expr),
|
||||
|
||||
StatementBody::Statement(expr) => {
|
||||
ctx.expr_ensure_semicolon = true;
|
||||
self.ensure_brackets_expr(ctx, expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ impl GenRust for StatementBody {
|
||||
match self {
|
||||
Self::Expression(expr) => expr.gen_rust(ctx, cg),
|
||||
Self::Statement(stmt) => {
|
||||
ctx.expr_ensure_semicolon = true;
|
||||
stmt.gen_rust(ctx, cg);
|
||||
cg.add(";");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user