fix: Move DropGuards to the end of their parent structs.
#8353
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.
Connections
None
Description
Currently, some structures in vulkan and gles have
DropGuards. Those are intended to allow creation ofwgpu_halstructs, such asDevice, from their raw counterparts initialized manually by the user. The drop guard signals to the user when the resource is not used by wgpu anymore so that they know it can be cleaned up.The problem is that
DropGuards are not last members ofwgpu_halstructs. Struct's fields are dropped in declaration order. This can lead to problems, such as the fields defined later in the struct requiring the underlying raw structure to be alive in order to free themselves properly, and the raw structure not being alive because theDropGuardwas dropped earlier.This patch moves the drop guards to the end of their parent structs.
Testing
Not sure how to test this or if testing is necessary
Squash or Rebase?
Squash I guess...
Checklist
cargo fmt.taplo format.cargo clippy --tests. If applicable, add:--target wasm32-unknown-unknowncargo xtask testto run tests.181 failed tests, with and without the changes
CHANGELOG.mdentry.