Say I have this macro definition:
#[proc_macro_derive(Builder, attributes(builder, group, groups))]
#[proc_macro_error]
pub fn derive_builder(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
// -- snip --
}
And I want to deprecate group, and have users use groups instead. You can't simply do:
#[proc_macro_derive(Builder, attributes(builder, #[deprecated] group, groups))]
And throwing warnings is currently only available on nightly
How do I tell users to phase out the use of group?
Just like with
compile_error!(), expand to a call to a deprecated function. Probably, the best way is to have a deprecated exported function from your macro's support lib:And expand to something like:
Of course, make sure to set the correct span so the error points to the right location.