Handling "local" proc_macro definitions

I'm currently working on a new crate that I plan on publishing. I've added a proc macro to generate a bunch of extra code that I need in certain situations. As I understand it, I cannot export anything other than a proc_macro from a proc_macro crate, so I've made a private sub-package.

I've currently got it set up like this:


In my_lib/Cargo.toml I have my_proc_macro = { path = "./my_proc_macro" }.

However, I can't publish this because you can't publish a crate with a path dependency.

So, is my only option here to publish this extra crate for the sole purpose of consuming the macro in the one lib this code already lives under?

I've done a bunch of Googling. Seen a heap of RFCs. I can't find anything concrete on how to fix this.

I think you need to create a second public crate. This Pre-RFC discussion LINK wants to address that issue but it’s not even an official RFC yet so I would not expect an alternate solution in the near future.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.