mirror of
https://github.com/horizon-rust/horizon-mixins.git
synced 2026-12-03 19:34:02 +07:00
[GH-ISSUE #1] Support HEAD-only hooks on methods containing macros such as matches! #3
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#3
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 @rdbtCVS on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon-mixins/issues/1
Request
Could HEAD-only injections support ordinary Rust functions whose bodies contain macros such as
matches!, when the original body can be preserved unchanged?The use case is observing keyboard input at Horizon's shared physical-key handler. We only need a noncancellable callback before the original method executes, without selecting anything inside a macro or rewriting returns.
What currently happens
With horizon-mixins
0500ff24aa5933fca95a877ef41125353c4b4fe3(also the current main revision when checked), planning a HEAD injection on this target fails:e1b2b0b2fdf5962a30fb5de31b0c1bd6829d9083crates/horizon-client/src/game/debug_keys.rshorizon_client::game::debug_keys::Game<'_>::debug_keyThe method contains
matches!calls. The rejection happens during planning, before host compilation.A declaration targeting this boundary has this shape:
The helper would receive the key/action, then let the original method continue.
Why this boundary matters
Both real keyboard events and normal
horizon-ctl key … tapcommands pass throughdebug_key. The alternativemapped_keyboundary does not receive normal control-socket key taps, so it cannot exercise the same mod input handler in controlled gameplay tests.Suggested scope
This seems like an extension of the existing preserved-body HEAD support for closures and
?, following the usual Mixin HEAD semantics: call the handler first, then execute the original body unchanged.Please retain stricter restrictions for interior/RETURN hooks, combinations requiring body analysis, unresolved cfg and attribute macros. No macro expansion or injection into macro contents is requested.
A regression fixture could verify that a HEAD hook on a method containing
matches!compiles, invokes the callback once, and preserves the original return value, early returns and destruction behavior. If arbitrary body macros cannot safely be supported, a narrower supported case or explanation would also help.