-
-
Notifications
You must be signed in to change notification settings - Fork 191
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
Fix #[func]-like attrs being ignored with macros below them #442
Conversation
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-442 |
94ee2f3
to
bc87b5e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Can you reference the symbols somewhere in Rust code (assign constant or function result to dummy value)? This would test that the symbols are indeed present.
#[cfg(all())] | ||
#[constant] | ||
const CONST_SHOULD_STILL_BE_RECOGNIZED_WITH_SIMPLE_PATH_ATTRIBUTE_ABOVE_CONST_ATTR: bool = true; | ||
|
||
#[constant] | ||
#[cfg(all())] | ||
const CONST_SHOULD_STILL_BE_RECOGNIZED_WITH_SIMPLE_PATH_ATTRIBUTE_UNDER_CONST_ATTR: bool = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use "below" instead of "under", and "constant" instead of "const".
Also, can the identifiers be a bit shorter? "should still be recognized" can be shortened to just "recognized".
Same applies to functions 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, and done! 😁
bc87b5e
to
78125a4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot!
Regarding failed clippy, this is addressed in #441, so I might merge that one first (given readiness).
4ef7561
to
5835012
Compare
Replaced |
This fixes the bug mentioned in #379 (comment).
To better explain the problem, consider the following modified code from the Dodge the Creeps example.
Note:
#[cfg(all())]
is a#[cfg]
check which should always pass / be a tautology (something like#[cfg(TRUE)]
, but that doesn't work by itself). This PR does not fix (yet) errors which appear when#[cfg]
removes the function.Before this PR: compile-time error:
After this PR: compiles.
The problem, as mentioned in my original response, is that the
extract_attributes
function would keep re-assigning thefound: Option<BoundAttr>
variable even after a#[func]
-like attr was already found, thus setting it toNone
when some unrecognized attribute appeared under#[func]
. This fixes the problem by just skipping unrecognized attributes -found
is only re-assigned if a#[func]
-like attribute is actually found (and this preserves the error when two consecutive#[func]
-like attributes are specified).Added tests under
itest
.(Also no idea why clippy is failing here lol, I didn't change that file!)