-
Notifications
You must be signed in to change notification settings - Fork 187
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
generator: Apply must_use
attributes to all Vulkan structs
#845
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
I think you mean stack, but yeah. |
Ralith
approved these changes
Dec 4, 2023
Yup, that's most common, though either works when it can be mutably borrowed while having a longer lifetime. |
MarijnS95
force-pushed
the
builder-must_use
branch
from
December 5, 2023 19:40
7d245e5
to
7280e78
Compare
MarijnS95
changed the title
generator: Apply
generator: Apply Dec 5, 2023
must_use
attributes to all struct setter functionsmust_use
attributes to all Vulkan structs
MarijnS95
force-pushed
the
builder-must_use
branch
from
December 5, 2023 19:41
7280e78
to
fc39cd0
Compare
Reworded the commit message to mention |
MarijnS95
commented
Dec 5, 2023
MarijnS95
commented
Dec 5, 2023
MarijnS95
force-pushed
the
builder-must_use
branch
from
December 5, 2023 20:20
fc39cd0
to
67125e9
Compare
All structs are marked as `Copy`, and builders move `self` for a convenient builder pattern directly on `default()` (using `&mut` requires requires first keeping the instance alive in a `let` binding). This however leads to builder functions accidentally moving a copy of `self`, mutating it, and dropping the result directly when the caller did not consume the returned value in ad-hoc field updates, in turn leaving the author confused why their code compiles without warnings while the struct was not updated. Annotating all Vulkan structs with `#[must_use]` should at least give them an idea why.
MarijnS95
force-pushed
the
builder-must_use
branch
from
December 5, 2023 21:05
67125e9
to
a2fa06f
Compare
Ralith
approved these changes
Dec 5, 2023
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.
All structs are marked as
Copy
, and builders moveself
for a convenient builder pattern directly ondefault()
(using&mut
requires first keeping the instance alive in alet
binding). This however leads to builder functions accidentally moving a copy ofself
, mutating it, and dropping the result directly when the caller did not consume the returned value in ad-hoc field updates, in turn leaving the author confused why their code compiles without warnings while the struct was not updated.Annotating all Vulkan structs with
#[must_use]
should at least give them an idea why, especially because of Rust allowing us to set a custom message.