Structured cleanup and control flow ยท PR #4718
Separate argument and function-body Drop scopes
Objective
Put parameter Drops and body-local Drops in separate nested scopes.
Why it was needed
Function parameters exist before the body and stay alive until after body locals. They belong in an outer Drop scope.
gccrs already produced the expected order, but it kept parameters and body locals in one candidate list.
Separate scopes record this structure directly and match rustc: clean the body first, then the parameters.
Main changes
- Creates the argument scope before compiling function parameters.
- Registers parameter Drop candidates directly in the argument scope.
- Compiles the function body in a nested scope.
- Cleans the body scope first, so body locals are dropped before parameters.
Test case
drop-function-params.rs: A relevant existing test for named and wildcard parameters. Its expected output checks that each body local drops before its parameter.