Open jakobhellermann opened 4 years ago
Nice!
Yeah proc_macro::TokenStream can't exist except inside code built with --crate-type proc-macro
. That is why proc-macro2 exists.
I see. I assume it is not possible to [patch]
proc-macro itself?
Then I guess search+replace and hope for the best is the best approach for cargo watt
.
I made a cargo subcommand called cargo watt, which aims to improve the tooling listed in the README.
Currently, it does two things:
Initially I wanted to replace
with
but that doesn't work because Into does not exist in wasm .
So my solution was to just replace the TokenStreams and hope for the best, while also using a patched version of syn which basically just has all instances of
proc_macro
replaced withproc_macro2
.This actually works for quite a few crates (e.g.
serde-derive
,typed-builder
,tracing-attributes
) but it doesn't for some other ones (everything depending onsynstructure
and some others).Now I am wondering: Is it fundamentally impossible to provide the
From
-impls becauseproc-macro
just doesn't exist in wasm, or would it be possible to do this transformation in some other way?