From edfd3b9f8fc9a380e8cc73350f558997ba32738d Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Mon, 13 Mar 2023 21:43:07 +0100 Subject: [PATCH] generator: Keep deprecated `MIRROR_CLAMP_TO_EDGE_KHR` alias Somehow this stuck along when we removed all the other deprecated aliases, because the comment annotation didn't match up with what was normally used (but we did write a special `#[deprecated = ..]` annotation based on `"Alias"`). Now that this all has been normalized in `vk.xml` behind a standardized `deprecated="reason"` attribute we have to go out of our way to keep this constant alias alive. --- ash/src/vk/extensions.rs | 2 ++ generator/src/lib.rs | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ash/src/vk/extensions.rs b/ash/src/vk/extensions.rs index bee1c89..2b130f1 100644 --- a/ash/src/vk/extensions.rs +++ b/ash/src/vk/extensions.rs @@ -1538,6 +1538,8 @@ impl KhrSamplerMirrorClampToEdgeFn { impl SamplerAddressMode { #[doc = "Note that this defines what was previously a core enum, and so uses the 'value' attribute rather than 'offset', and does not have a suffix. This is a special case, and should not be repeated"] pub const MIRROR_CLAMP_TO_EDGE: Self = Self(4); + #[deprecated = "Introduced for consistency with extension suffixing rules"] + pub const MIRROR_CLAMP_TO_EDGE_KHR: Self = Self::MIRROR_CLAMP_TO_EDGE; } impl ImgFilterCubicFn { #[inline] diff --git a/generator/src/lib.rs b/generator/src/lib.rs index b1b8ca0..ab9788e 100644 --- a/generator/src/lib.rs +++ b/generator/src/lib.rs @@ -1112,7 +1112,10 @@ pub fn generate_extension_constants<'a>( continue; } - if enum_.deprecated.is_some() { + if enum_.deprecated.is_some() + // TODO: Remove deprecated alias on next breaking release + && enum_.name != "VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE_KHR" + { continue; } @@ -1460,10 +1463,19 @@ pub fn bitflags_impl_block( ) -> TokenStream { let variants = constants .iter() - .filter(|constant| !constant.is_deprecated()) + .filter(|constant| { + !constant.is_deprecated() + // TODO: Remove deprecated alias on next breaking release + || constant.variant_ident(enum_name) == "MIRROR_CLAMP_TO_EDGE_KHR" + }) .map(|constant| { let variant_ident = constant.variant_ident(enum_name); - let notation = constant.doc_attribute(); + let notation = if variant_ident == "MIRROR_CLAMP_TO_EDGE_KHR" { + let comment = constant.formatted_notation(); + Some(quote!(#[deprecated = #comment])) + } else { + constant.doc_attribute() + }; let constant = constant.constant(enum_name); let value = if let Constant::Alias(_) = &constant { quote!(#constant)