]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: add drops at the end of function bodies
authorlishin <lishin1008@gmail.com>
Tue, 9 Jun 2026 16:04:55 +0000 (17:04 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 25 Jun 2026 17:21:39 +0000 (19:21 +0200)
commit8bc32075bb2e59bc4915093c87e488ec30f2c2b3
tree0fb51b1fa7e59d903915aee70781fce060107723
parentc26a3a7461a511b14d7ae1090a757e3616aced21
gccrs: add drops at the end of function bodies

Add function-scope Drop support for the implicit return case.
Add two test cases. This does not yet support explicit return.

gcc/rust/ChangeLog:

* backend/rust-compile-base.cc (HIRCompileBase::compile_function_body):
Add drop calls at the end of function bodies.

gcc/testsuite/ChangeLog:

* rust/execute/drop-function-scope-unit.rs: New test.
* rust/execute/drop-function-scope.rs: New test.

Signed-off-by: lishin <lishin1008@gmail.com>
gcc/rust/backend/rust-compile-base.cc
gcc/testsuite/rust/execute/drop-function-scope-unit.rs [new file with mode: 0644]
gcc/testsuite/rust/execute/drop-function-scope.rs [new file with mode: 0644]