-
Notifications
You must be signed in to change notification settings - Fork 72
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: only emit must_use hint when wdf function has return type #122
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…as_ptr` clippy lints
wmmc88
force-pushed
the
better-macro-must-use
branch
3 times, most recently
from
March 29, 2024 22:57
1b95387
to
7c6aa49
Compare
…restructured code to be more testable,
wmmc88
force-pushed
the
better-macro-must-use
branch
from
April 3, 2024 00:34
655afb8
to
0044856
Compare
wmmc88
commented
Apr 3, 2024
wmmc88
force-pushed
the
better-macro-must-use
branch
from
April 5, 2024 19:53
1bc40b9
to
66d1dea
Compare
hamzamust
approved these changes
Apr 10, 2024
ayodejiige
approved these changes
Apr 24, 2024
crates/wdk-macros/tests/inputs/trybuild/wdf_device_create_unused_return_type.rs
Show resolved
Hide resolved
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, the macro would emit
must_use
regardless of the return type WDF function being called, including ones that returned()
. Now, the macro will parse the generated bindings to determine if there is a return type, before emittingmust_use
. this removes the need for ugly code blocks to avoid compiler warnings like:After this change:
This also stabilizes the
must_use
functionality so that its available without thenightly
feature enabled.cargo bloat
was used to validate that the new implementation with the nested function does not increase code size in release mode.To make the macro more unit-testable and maintainable, its logic was broken into 4 distinct parts that are individually unit-testable:
Inputs
Inputs
, generate new AST fragments inDerivedASTFragments
DerivedASTFragments
to create the major blocks of the macro generates inIntermediateOutputASTFragments
IntermediateOutputASTFragments
into the tokens output by the macroCurrently blocked on:
manual_c_str_literals
andref_as_ptr
clippy lints #127 merging