mirror of
https://github.com/horizon-rust/horizon-mixins.git
synced 2026-12-03 19:34:02 +07:00
[PR #15] [MERGED] feat(plan): let return hooks move plain closures inside exit values #21
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
horizon-rust/horizon-mixins#21
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/horizon-rust/horizon-mixins/pull/15
Author: @reservedbytes
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154
Base:
main← Head:feat/return-closures-in-exits📝 Commits (1)
adc34e5feat(plan): let return hooks move plain closures inside exit values📊 Changes
5 files changed (+49 additions, -13 deletions)
View changed files
📝
README.md(+1 -1)📝
crates/horizon-mixins-cli/tests/cases/returns.rs(+35 -3)📝
crates/horizon-mixins-core/src/plan.rs(+4 -4)📝
docs/advanced-injections.md(+6 -2)📝
docs/mixin-api.md(+3 -3)📄 Description
What and why
#9 let RETURN plan in functions with closures outside the values it moves, a closure inside a
returnoperand or the tail was still refusedThat is a common shape in Horizon, e.g.
horizon_core::biome::noise_quart_at_blockis one line,[block.x, block.y, block.z].map(|v| v >> 2), and a RETURN hook on it fails withE_UNSUPPORTED_CONTROL_FLOWRETURN wraps the whole exit value in the helper call and
ReturnRewritenever looks inside closures, so a closure there just moves into the helper's argument with the rest of the valueWhat the closure holds isn't part of that value: its own
returnleaves the closure, not the target, and its locals already stay out of ordinals (#9)So
exit_value_errorno longer counts a closure in an exit value as an error and doesn't look inside itStill refused:
?,awaitorunsafeinside any closure, since the whole-body check still descends into them?outside closures, since it's an exit RETURN would missMODIFY_VARIABLE (#14) and the other hooks keep their own checks, nothing changes for them
On Horizon nightly
1da354b, checking every function as a RETURN target, 2,344 more functions plan and none that planned before is refusedRETURN on
noise_quart_at_block,Game::toast_slots_usedandagent::face_name(closures in each tail) went fromE_UNSUPPORTED_CONTROL_FLOWto planning and applying, and the staged game compilesChecks
cargo fmt --all --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo test --workspace --locked(98 passed, new testreturn_hooks_move_closures_in_exit_values_with_the_value, which fails without the change, and the refusal test now also covers?and async closures inside an exit value)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.