Use #[diagnostic::on_unimplemented]
to improve padding error messages
#1696
Labels
blocking-next-release-publicization
experience-hard
This issue is hard, and requires a lot of experience
help wanted
Extra attention is needed
Currently, the error message emitted when a type has padding (but isn't supposed to) is quite bad:
zerocopy/src/lib.rs
Lines 3783 to 3805 in 782c12f
Using
#[diagnostic::on_unimplemented]
, we should be able to significantly improve this error message.However, it'd be ideal if we changed the way we do enforcement. Currently, the type in question shows up as an argument in the
HasPadding
type. In order to get the best ergonomics, we need to the type to be in a position where#[diagnostic::on_unimplemented]
has access to its name. In particular, that means that it either needs to show up as an argument to the trait that isn't implemented ({T}
in the attribute's message, label, or note) or as the type that the trait isn't implemented for ({Self}
in the attribute's message, label, or note).The text was updated successfully, but these errors were encountered: