diff options
Diffstat (limited to 'gcc/rust/backend/rust-compile-item.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-item.h | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h index 83e4451..b08c49e 100644 --- a/gcc/rust/backend/rust-compile-item.h +++ b/gcc/rust/backend/rust-compile-item.h @@ -265,28 +265,8 @@ public: ctx->push_fn (fndecl, return_address); - // compile the block - function_body->iterate_stmts ([&] (HIR::Stmt *s) mutable -> bool { - CompileStmt::Compile (s, ctx); - return true; - }); - - if (function_body->has_expr () && function_body->tail_expr_reachable ()) - { - // the previous passes will ensure this is a valid return - // dead code elimination should remove any bad trailing expressions - Bexpression *compiled_expr - = CompileExpr::Compile (function_body->expr.get (), ctx); - rust_assert (compiled_expr != nullptr); - - auto fncontext = ctx->peek_fn (); - - std::vector<Bexpression *> retstmts; - retstmts.push_back (compiled_expr); - auto s = ctx->get_backend ()->return_statement ( - fncontext.fndecl, retstmts, function_body->expr->get_locus_slow ()); - ctx->add_statement (s); - } + compile_function_body (fndecl, function.function_body, + function.has_function_return_type ()); ctx->pop_block (); auto body = ctx->get_backend ()->block_statement (code_block); @@ -297,7 +277,6 @@ public: } ctx->pop_fn (); - ctx->push_function (fndecl); } |