Closed k3d3 closed 1 year ago
Hi!
For the moment the proc macro does not support using generics. It's something that is on my to-do list but I haven't gotten around to it yet. For now if you want to use generics you will have to manually write the state machine as in the no_macro examples.
In the mean time I'll see if I can add an error message to the proc macro when it encounters generics so it is at least clear to the user it's not supported.
I'll also keep this issue open as I agree that generics should be supported eventually.
Leaving a comment here as I'd love to use generics with macros, too. I see that you've added a working example on the master branch so looks like it's coming soon 👀
Yes, I've been working on it and it will be part of the 0.3 update. What's there seems to working pretty well, but I still have some refactoring to do and add additional tests.
Added in 5b910ce.
As generics and the associated bounds can get quite complicated it's possible that there are edge case that the macro doesn't yet handle. If you encounter such a situation feel free to open an issue and I'll take a look ;).
This is perfect. Thank you!
I'm trying to add an FnMut to a state machine via:
in order to allow a state machine to emit a signal as it handles transitions. Unfortunately, adding generics like that to the state machine appears to cause a proc macro panic that just says
error: custom attribute panicked
withmessage: expected function call expression
When I run
RUSTFLAGS="-Z proc-macro-backtrace" cargo +nightly check
, I get the following lines in the backtrace:Unfortunately for some reason I can't seem to get line numbers for the lines that occur within statig_macro, however I tried to narrow down the line causing the issue, and it appears to be this line in
lower.rs
, in thelower_state
function:Unfortunately I'm not very good with proc macros, so I'm not sure how to further debug this, but hopefully this is helpful?
Alternatively, perhaps I just screwed something up. In any case, let me know if there's anything else I can do to help diagnose this.
Thanks!