← Contribution overview

Structured cleanup and control flow ยท PR #4711

Apply try/finally cleanup to function-scope Drops

Merged

Objective

Use the try/finally cleanup path for function scopes, constant items, and closures.

Why it was needed

Block scopes already used TRY_FINALLY_EXPR, but function scopes still emitted Drop calls from separate code paths. gccrs therefore had two cleanup designs.

This PR builds the function cleanup once when its scope closes and uses the same structured path for functions, constant items, and closures.

Main changes

  • Removes the individual function-scope Drop-emission calls.
  • Builds the function cleanup once when the scope is popped.
  • Applies the same cleanup path to constant-item and closure bodies.
  • Removes the old immediate-emission helper.

Verification

This PR did not change any test files.

Its description records that the existing function-scope test still passed.

View PR on GitHub ← Contribution overview