Skip to content

Commit e6d80ba

Browse files
authored
generator: Apply must_use attributes to all Vulkan structs (#845)
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.
1 parent befb8cd commit e6d80ba

File tree

3 files changed

+999
-9
lines changed

3 files changed

+999
-9
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3030
- Added `VK_NV_cuda_kernel_launch` device extension (#805)
3131
- Added `descriptor_count()` setter on `ash::vk::WriteDescriptorSet` (#809)
3232
- Added `*_as_c_str()` getters for `c_char` pointers and `c_char` arrays (#831)
33+
- Added `#[must_use]` to Vulkan structs to make it more clear that they are moved by the builder pattern (#845)
3334

3435
### Changed
3536

0 commit comments

Comments
 (0)