I’m contributing in a library which uses proc macro to generate JSON and some structs based on trait signature.
The problem is that in this case this library adds
serde_json as a runtime dependency while it’s only used when building the library. It makes sense to move it to the
build.rs and make serde dev-dependency. But here is a catch: I didn’t find any way to convert source file into token stream.
syn crate only works if you have TokenStream, but in my case I don’t have.
How could it be done? Am I missing something or there is no way to do it with today architecture? It looks quite common that your attribute may use some dependencies that aren’t actually runtime ones.
If you wonder why I’m worried: there is a known bug (feature?) in the cargo that it cannot resolve one library linked as std and no_std (I have seen 6 or 7 issues about it). And this is exactly what I have. So I want to move one into dev-deps to resolve the conflict.