Skip to content

Commit

Permalink
generator: Apply must_use attributes to all Vulkan structs (#845)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MarijnS95 committed Dec 5, 2023
1 parent befb8cd commit e6d80ba
Show file tree
Hide file tree
Showing 3 changed files with 999 additions and 9 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `VK_NV_cuda_kernel_launch` device extension (#805)
- Added `descriptor_count()` setter on `ash::vk::WriteDescriptorSet` (#809)
- Added `*_as_c_str()` getters for `c_char` pointers and `c_char` arrays (#831)
- Added `#[must_use]` to Vulkan structs to make it more clear that they are moved by the builder pattern (#845)

### Changed

Expand Down
Loading

0 comments on commit e6d80ba

Please sign in to comment.