mirror of
https://github.com/horizon-rust/horizon-mixins.git
synced 2026-12-03 19:34:02 +07:00
[GH-ISSUE #6] Support safe RETURN hooks for functions containing calls beneath references #2
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#2
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?
Originally created by @sofia-gros on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon-mixins/issues/6
Use case
I would like to customize the item stack returned by a server-side block-pick handler while preserving the host’s original result construction. A RETURN hook could add block-specific data without replacing the entire operation.
Observed behavior
Tested revisions:
cb1ad23022A RETURN injection targeting horizon_client::game::block_items::Game<'_>::picked_stack fails during planning, even when its helper returns the original Option unchanged:
E_UNSUPPORTED_CONTROL_FLOW: calls beneath a reference may change temporary lifetimes
The target function contains an expression such as Some(&Tag::Compound(all)).
This appears consistent with the safety restrictions in the tested revision. I am requesting additional supported coverage, rather than reporting the rejection itself as a bug. I have not verified whether the restriction remains in newer revisions.
Alternative considered
A cancellable HEAD hook on the same function plans and applies on the tested revision. A HEAD-based implementation has subsequently been tested for LAN block picking. It replaces the result for intercepted blocks, however, rather than modifying the original result, so it must reproduce the relevant host behavior.
The earlier HEAD/macro restriction discussed in #1 and addressed by #2 is separate from this RETURN restriction.
Request
Could a narrowly scoped, safe RETURN transformation support this case? Alternatively, is there an existing supported approach for modifying the original result without duplicating its construction?
Any extension should preserve temporary lifetimes, evaluation order, borrowing, and control-flow semantics. I am not proposing that the existing safety checks simply be disabled.
@levzzz5154 commented on GitHub (Oct 30, 2026):
🤖 Agent: RETURN hooks on functions shaped like
picked_stackare supported as of5140cdf(#9). References to calls (such asSome(&Tag::Compound(all))) and plain closures are now allowed anywhere except inside the returned values themselves; the rest of the body is left as written, so temporaries keep their lifetimes. The$valuebinding type has to be spelled exactly as the target spells its result:Option<ItemStack>, otherwise planning fails withE_INVALID_BINDING. A launcher build uses this once a bundle names this horizon-mixins revision.