mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-10-29 21:42:26 +00:00
Clean up BufferContents
derive macro expansion further (#2588)
This commit is contained in:
parent
ba278ac193
commit
50b3b7a42f
@ -165,16 +165,10 @@ pub fn derive_buffer_contents(crate_ident: &Ident, mut ast: DeriveInput) -> Resu
|
|||||||
|
|
||||||
let bounds = bound_types.into_iter().map(|ty| {
|
let bounds = bound_types.into_iter().map(|ty| {
|
||||||
quote_spanned! { ty.span() =>
|
quote_spanned! { ty.span() =>
|
||||||
const _: () = {
|
// HACK: This works around Rust issue #48214, which makes it impossible to put these
|
||||||
// HACK: This works around Rust issue #48214, which makes it impossible to put
|
// bounds in the where clause of the trait implementation where they actually belong
|
||||||
// these bounds in the where clause of the trait implementation where they actually
|
// until that is resolved.
|
||||||
// belong until that is resolved.
|
let _: ::vulkano::buffer::AssertParamIsBufferContents<#ty>;
|
||||||
#[allow(unused)]
|
|
||||||
fn bound #impl_generics () #where_clause {
|
|
||||||
fn assert_impl<T: ::#crate_ident::buffer::BufferContents + ?Sized>() {}
|
|
||||||
assert_impl::<#ty>();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -187,11 +181,11 @@ pub fn derive_buffer_contents(crate_ident: &Ident, mut ast: DeriveInput) -> Resu
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn ptr_from_slice(slice: ::std::ptr::NonNull<[u8]>) -> *mut Self {
|
unsafe fn ptr_from_slice(slice: ::std::ptr::NonNull<[u8]>) -> *mut Self {
|
||||||
|
#( #bounds )*
|
||||||
|
|
||||||
#ptr_from_slice
|
#ptr_from_slice
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#( #bounds )*
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +92,7 @@ use std::{
|
|||||||
error::Error,
|
error::Error,
|
||||||
fmt::{Display, Formatter},
|
fmt::{Display, Formatter},
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
|
marker::PhantomData,
|
||||||
ops::Range,
|
ops::Range,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
@ -1066,3 +1067,7 @@ impl From<Subbuffer<[u32]>> for IndexBuffer {
|
|||||||
Self::U32(value)
|
Self::U32(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This is intended for use by the `BufferContents` derive macro only.
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub struct AssertParamIsBufferContents<T: BufferContents + ?Sized>(PhantomData<T>);
|
||||||
|
Loading…
Reference in New Issue
Block a user