-
-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Macros in macros #379
Comments
Is something like |
Good point! Macros inside attributes are currently not supported either, but I'm not sure if we want to support them at all. Compared to the other use cases, they seem quite rare. |
Yeah, that's why I wanted to clarify - the lack of them makes attributes feel a bit less semantically Rust-y, but usually they appear as a result of hacks or workarounds for things that aren't in gdext yet, so I'm not sure if they're worth adding |
A report on the state of thingsSo, I just spent quite some time debugging the I was wondering why The reason is this particular line: gdext/godot-macros/src/class/godot_api.rs Line 375 in 88a7934
The TL;DR is that, when parsing #[godot_api] applied on inherent This means that, when Then why does my PR #439 work (and not cause Therefore, (This also raises the question of whether we should even allow non-Godot FFI functions to appear in Note that all of this happens because #[godot_api] applied on the Ideally, we could solve this by manually expanding the unrecognized attributes before generating the FFI glue. Sounds easy, right? Well, unfortunately, it isn't possible at the moment as it requires a currently unstable feature called Until that feature is stabilized (if ever), though, we'll have to make do. An important conclusion here is that we can't currently work around the order of execution of proc macros in a sane way (currently, proc macros are evaluated "outside-in", that is, the In the following responses, I'll try to detail some possible solutions and ways forward, based on my research on this topic. |
Possible solutions and conclusions
|
|
Thanks a lot for all this effort! ❤️ To move this into practice, we could start defining concrete test cases that a user would expect to work. We can then measure and trade off solutions based on how well they solve them. For this, it's great to have a nuanced and detailed record like you wrote. We could start with simple ones like these + the ones you already added in #439: #[func]
fn func();
#[cfg(FALSE)] // idiom for something not defined
#[func]
fn func();
#[func]
#[cfg(FALSE)]
fn func();
... |
I added venial support for declarative macros in PoignardAzur/venial#50. I'd say this is good for now, if we encounter new cases, we can open a new issue 🙂 |
Our proc-macros don't work very well if the body contains declarative macros. Sometimes, other (non-gdext) attributes like
#[allow(...)]
also cause problems.This should be addressed, possibly needs upstream
venial
changes.Ideally, the order of attribute macros should not matter, either.
The text was updated successfully, but these errors were encountered: