From: Lishin <[email protected]>
Let explicit returns handled by try-finally cleanup.
Remove the manual drop emission and related helpers.
gcc/rust/ChangeLog:
* backend/rust-compile-drop-builder.cc
(DropBuilder::get_block_drop_candidate_stack): Remove.
* backend/rust-compile-drop-builder.h
(DropBuilder::get_block_drop_candidate_stack): Remove declaration.
* backend/rust-compile-expr.cc
(CompileExpr::visit (HIR::ReturnExpr &)): Stop emitting drops manually.
Store the return statement in translated.
Signed-off-by: Lishin <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.
Commit on github:
https://github.com/Rust-GCC/gccrs/commit/adde96a15ced7011e432dadee73c19fc59eb9178
The commit has NOT been mentioned in any issue.
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/4621
gcc/rust/backend/rust-compile-drop-builder.cc | 7 -------
gcc/rust/backend/rust-compile-drop-builder.h | 2 --
gcc/rust/backend/rust-compile-expr.cc | 5 ++---
3 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/gcc/rust/backend/rust-compile-drop-builder.cc
b/gcc/rust/backend/rust-compile-drop-builder.cc
index fb01fc3db..e0947a787 100644
--- a/gcc/rust/backend/rust-compile-drop-builder.cc
+++ b/gcc/rust/backend/rust-compile-drop-builder.cc
@@ -38,12 +38,5 @@ DropBuilder::peek_block_drop_candidates ()
return ctx.block_drop_candidates.back ();
}
-const std::vector<std::vector<DropCandidate>> &
-DropBuilder::get_block_drop_candidate_stack () const
-{
- rust_assert (!ctx.block_drop_candidates.empty ());
- return ctx.block_drop_candidates;
-}
-
} // namespace Compile
} // namespace Rust
\ No newline at end of file
diff --git a/gcc/rust/backend/rust-compile-drop-builder.h
b/gcc/rust/backend/rust-compile-drop-builder.h
index ca6601705..36e3cdc1e 100644
--- a/gcc/rust/backend/rust-compile-drop-builder.h
+++ b/gcc/rust/backend/rust-compile-drop-builder.h
@@ -33,8 +33,6 @@ public:
void note_simple_drop_candidate (HirId hirid, location_t locus);
std::vector<DropCandidate> &peek_block_drop_candidates ();
- const std::vector<std::vector<DropCandidate>> &
- get_block_drop_candidate_stack () const;
private:
Context &ctx;
diff --git a/gcc/rust/backend/rust-compile-expr.cc
b/gcc/rust/backend/rust-compile-expr.cc
index b76f1bcc2..4be42161b 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -294,11 +294,10 @@ CompileExpr::visit (HIR::ReturnExpr &expr)
= Backend::var_expression (fncontext.ret_addr, expr.get_locus ());
}
- CompileDrop (ctx).emit_return_scope_drop_calls ();
-
tree return_stmt = Backend::return_statement (fncontext.fndecl, return_value,
expr.get_locus ());
- ctx->add_statement (return_stmt);
+
+ translated = return_stmt;
}
void
--
2.54.0