The new message implementation macro, message_ty!, is written as a
procedural macro to make the maintenance burden easier. Declarative
macros may be conceptually simpler, but attempting to make
impl_message! work for either struct or enum members was hard
and got very messy very fast.
Additionally rust#22694 prevents using declarative macros
to generate item fragments (e.g., enum variants inside enum Foo {}),
which makes creating a maintainable decl macro quite hard.
It ended up being less effort to both rewrite it as a proc macro and
also add support for enum members. As a side effect, this macro
provides better error spans when it is provided with invalid input
(instead of the generic no rules expected the token {token} error).
The new message implementation macro,
message_ty!
, is written as a procedural macro to make the maintenance burden easier. Declarative macros may be conceptually simpler, but attempting to makeimpl_message!
work for eitherstruct
orenum
members was hard and got very messy very fast.Additionally rust#22694 prevents using declarative macros to generate item fragments (e.g., enum variants inside
enum Foo {}
), which makes creating a maintainable decl macro quite hard.It ended up being less effort to both rewrite it as a proc macro and also add support for
enum
members. As a side effect, this macro provides better error spans when it is provided with invalid input (instead of the genericno rules expected the token {token}
error).