diff --git a/ash/src/vk/definitions.rs b/ash/src/vk/definitions.rs index c0b537d..dcc9d86 100644 --- a/ash/src/vk/definitions.rs +++ b/ash/src/vk/definitions.rs @@ -52045,9 +52045,9 @@ unsafe impl<'a> TaggedStructure for GetLatencyMarkerInfoNV<'a> { } impl<'a> GetLatencyMarkerInfoNV<'a> { #[inline] - pub fn timings(mut self, timings: &'a mut [LatencyTimingsFrameReportNV<'a>]) -> Self { + pub fn timings(mut self, timings: &'a mut [LatencyTimingsFrameReportNV<'_>]) -> Self { self.timing_count = timings.len() as _; - self.p_timings = timings.as_mut_ptr(); + self.p_timings = timings.as_mut_ptr().cast(); self } } diff --git a/generator/src/lib.rs b/generator/src/lib.rs index 806c974..2b27ed6 100644 --- a/generator/src/lib.rs +++ b/generator/src/lib.rs @@ -1929,7 +1929,7 @@ fn derive_setters( let deprecated = member.deprecated.as_ref().map(|d| quote!(#d #[allow(deprecated)])); let param_ident = field.param_ident(); - let type_lifetime = has_lifetimes + let mut type_lifetime = has_lifetimes .contains(&name_to_tokens(&field.basetype)) .then(|| quote!(<'a>)); let param_ty_tokens = field.safe_type_tokens(quote!('a), type_lifetime.clone(), None); @@ -2018,14 +2018,20 @@ fn derive_setters( // TODO: Improve in future when https://github.com/rust-lang/rust/issues/53667 is merged id:6 if field.reference.is_some() && matches!(field.array, Some(vkxml::ArrayType::Dynamic)) { if let Some(ref array_size) = field.size { - let mut slice_param_ty_tokens = field.safe_type_tokens(quote!('a), type_lifetime.clone(), None); - let mut ptr = if field.is_const { quote!(.as_ptr()) + } else if let Some(tl) = &mut type_lifetime { + // Work around invariance with mutable pointers: + // https://github.com/ash-rs/ash/issues/837 + // https://doc.rust-lang.org/nomicon/subtyping.html#variance + *tl = quote!(<'_>); + quote!(.as_mut_ptr().cast()) } else { quote!(.as_mut_ptr()) }; + let mut slice_param_ty_tokens = field.safe_type_tokens(quote!('a), type_lifetime.clone(), None); + // Interpret void array as byte array if field.basetype == "void" && matches!(field.reference, Some(vkxml::ReferenceType::Pointer)) { slice_param_ty_tokens = quote!([u8]);