Skip to content

Commit 577d728

Browse files
committed
SQUASHME: Further solidify non-"dyn compatibility"
1 parent 04d3943 commit 577d728

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

Changelog.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Added `VK_EXT_metal_objects` device extension (#942)
1616
- Added `VK_AMD_anti_lag` device extension (#943)
1717
- Added `VK_KHR_video_queue`, `VK_KHR_video_encode_queue`, and `VK_KHR_video_decode_queue` device extensions (#965)
18-
- Added `AnyTaggedStructure` trait that is implemented for every (`dyn`amic) Vulkan structure. (#994)
1918

2019
### Changed
2120

@@ -30,7 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3029
- `push_next()` has been renamed to `extend()` and marked as `unsafe`. Users are encouraged to call `push()` for singular structs instead. (#909)
3130
- Changed and renamed `RawPtr::as_raw_ptr(&self)` trait function to a by-value `RawPtr::to_raw_ptr(self)` function. (#965)
3231
- All `Extends{Root}` traits have been replaced with a single `Extends<Root>` trait using generics. (#971)
33-
- Moved `push()` and `extend()` methods from individual Vulkan structs (builders) into the new `AnyTaggedStructure` trait. (#994)
32+
- Moved `push()` and `extend()` methods from individual Vulkan structs (builders) into the `TaggedStructure` trait. (#994)
33+
This trait must be imported in scope (`use ash::vk::TaggedStructure as _;`) to use the `push()` and `extend()` methods.
3434

3535
### Removed
3636

ash/src/vk.rs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub trait Handle: Sized {
5151

5252
/// Iterates through the pointer chain. Includes the item that is passed into the function. Stops at
5353
/// the last [`BaseOutStructure`] that has a null [`BaseOutStructure::p_next`] field.
54-
pub(crate) unsafe fn ptr_chain_iter<'a, T: TaggedStructure<'a> + ?Sized>(
54+
pub(crate) unsafe fn ptr_chain_iter<'a, T: TaggedStructure<'a>>(
5555
ptr: &mut T,
5656
) -> impl Iterator<Item = *mut BaseOutStructure<'_>> {
5757
let ptr = <*mut T>::cast::<BaseOutStructure<'_>>(ptr);
@@ -69,7 +69,7 @@ pub(crate) unsafe fn ptr_chain_iter<'a, T: TaggedStructure<'a> + ?Sized>(
6969
/// Structures implementing this trait are layout-compatible with [`BaseInStructure`] and
7070
/// [`BaseOutStructure`]. Such structures have an `s_type` field indicating its type, which must
7171
/// always match the value of [`TaggedStructure::STRUCTURE_TYPE`].
72-
pub unsafe trait TaggedStructure<'a> {
72+
pub unsafe trait TaggedStructure<'a>: Sized {
7373
const STRUCTURE_TYPE: StructureType;
7474

7575
/// Prepends the given extension struct between the root and the first pointer. This method is
@@ -81,13 +81,10 @@ pub unsafe trait TaggedStructure<'a> {
8181
/// # Panics
8282
/// If `next` contains a pointer chain of its own, this function will panic. Call `unsafe`
8383
/// [`Self::extend()`] to insert this chain instead.
84-
fn push<T: Extends<Self> + TaggedStructure<'a> + ?Sized>(mut self, next: &'a mut T) -> Self
85-
where
86-
Self: Sized,
87-
{
88-
// SAFETY: All implementors of `TaggedStructure` are required to have the `BaseOutStructure` layout
84+
fn push<T: Extends<Self> + TaggedStructure<'a>>(mut self, next: &'a mut T) -> Self {
85+
// SAFETY: All implementers of `TaggedStructure` are required to have the `BaseOutStructure` layout
8986
let slf_base = unsafe { &mut *<*mut _>::cast::<BaseOutStructure<'_>>(&mut self) };
90-
// SAFETY: All implementors of `TaggedStructure` are required to have the `BaseOutStructure` layout
87+
// SAFETY: All implementers of `T: TaggedStructure` are required to have the `BaseOutStructure` layout
9188
let next_base = unsafe { &mut *<*mut T>::cast::<BaseOutStructure<'_>>(next) };
9289
// `next` here can contain a pointer chain. This function refuses to insert the struct,
9390
// in favour of calling unsafe extend().
@@ -113,13 +110,7 @@ pub unsafe trait TaggedStructure<'a> {
113110
///
114111
/// The last struct in this chain (i.e. the one where `p_next` is `NULL`) must be writable
115112
/// memory, as its `p_next` field will be updated with the value of `self.p_next`.
116-
unsafe fn extend<T: Extends<Self> + TaggedStructure<'a> + ?Sized>(
117-
mut self,
118-
next: &'a mut T,
119-
) -> Self
120-
where
121-
Self: Sized,
122-
{
113+
unsafe fn extend<T: Extends<Self> + TaggedStructure<'a>>(mut self, next: &'a mut T) -> Self {
123114
// `next` here can contain a pointer chain. This means that we must correctly attach he head
124115
// to the root and the tail to the rest of the chain For example:
125116
//

0 commit comments

Comments
 (0)