Many libraries that contain procedural macros consist of two crates: a proc-macro
crate implementing the actual macro and a normal "main" crate that reexports or wraps the proc macro. This is done because proc-macro
crates cannot publicly export anything other than proc macros. Assuming the main crate is called foo
, the macro crate is usually called foo-derive
or foo-macros
.
This brings up a couple of questions about how to version the proc-macro
crate. Of course, the main crate follows semantic versioning. But should the macro crate follow it as well? I don't want people to use the macro crate directly, but only through the main crate. I clearly stated that in the proc-macro crate's description. I want to treat the macro crate as an implementation detail.
In that case, can I shouldn't need to follow semantic versioning, right? The main crate would then just require one exact version via foo-macro = "=0.0.4"
.
Is this fine? Or can something break with this approach? Are there some established best practices in the community?