Use Rust-1.78 #[diagnostic::on_unimplemented] to clarify push_next trait#915
Use Rust-1.78 #[diagnostic::on_unimplemented] to clarify push_next trait#915
#[diagnostic::on_unimplemented] to clarify push_next trait#915Conversation
There was a problem hiding this comment.
Awesome idea! The wording looks good to me. Could we link to e.g. https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkDeviceCreateInfo.html#VUID-VkDeviceCreateInfo-pNext-pNext? Not sure that's much more helpful than just linking the trait rustdoc, but it's authoritative and cross-referenced.
b0d679f to
f74d7f0
Compare
Good one, I didn't realize that the |
…` trait When a user passes an invalid type into `push_next()`, [since Rust 1.78] we can now customize the diagnostics error to more clearly decsribe what and why they are not allowed to pass a certain type into this structure instead of having to refer to the trait definition (which contains no docs either). [since Rust 1.78]: https://blog.rust-lang.org/2024/05/02/Rust-1.78.0.html#diagnostic-attributes
f74d7f0 to
dced885
Compare
| quote!(pub unsafe trait #extends_name {}) | ||
| let message = format!("`{{Self}}` is not allowed in the `pNext` chain of `vk::{name}`"); | ||
| let label = format!("`{{Self}}` does not extend `vk::{name}`"); | ||
| let note = format!("See the list of allowed extension structs at <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/{}.html#VUID-{}-pNext-pNext>", struct_.name, struct_.name); |
There was a problem hiding this comment.
Unsure if the link should be wrapped in <>, let me check some other diagnostics.
When a user passes an invalid type into
push_next(), since Rust 1.78 we can now customize the diagnostics error to more clearly decsribe what and why they are not allowed to pass a certain type into this structure instead of having to refer to the trait definition (which contains no docs either).This turns the following, rather obnoxious error:
Into something more digestible:
Please help me bike-shed the wording though! I was also hoping to find some upstream documentation (or a list of current extensions) based on the
vk.xmlstructextendsfield, to reference in anote =attribute.