Open Boscop opened 6 years ago
Apparently the way of writing proc-macros has changed, now it has to be done like this (for functionlike!()
proc-macros):
https://doc.rust-lang.org/unstable-book/language-features/proc-macro.html#function-like-procedural-macros
E.g.:
https://github.com/dtolnay/syn/blob/master/examples/lazy-static/lazy-static/src/lib.rs#L49-L50
https://github.com/dtolnay/syn/blob/master/examples/lazy-static/lazy-static/Cargo.toml#L8
With this, the proc-macro can also work on stable: https://github.com/dtolnay/proc-macro-hack
It seems this macro was generally broke for recent nightly builds, thanks to the efforts to stabilize proc-macro that split out some bits. I've made a few changes to get it building again with nightly (stable doesn't support proc_macros that expand into an expression). 0.1.1
with original $foo
syntax and 0.2.0
with {foo}
syntax. I did skim the rust issue you mentioned, and think there may still be some changes to how proc_macro vs proc_macro2 are used, but I haven't tried building on wasm or dug deep enough into the weeds yet to know what will/won't work.
Hm, it still doesn't work for me (on wasm32):
[Running: cargo check --message-format=json]
Updating registry `https://github.com/rust-lang/crates.io-index`
Downloading interpolate v0.1.2
Checking unicode-xid v0.1.0
Checking proc-macro2 v0.4.9
error: C:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\proc-macro2-0.4.9\src\lib.rs:50: can't find crate for `proc_macro`
error: C:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\proc-macro2-0.4.9\src\lib.rs:50: can't find crate
error: Could not compile `proc-macro2`.
Yeah.. I suspect this comment: https://github.com/rust-lang/cargo/issues/5825#issuecomment-408638066 describes what I'd need to change. I haven't gone through the wasm setup, so if it's just a few commands to setup, could you point me steps I'd need to repro this?
The steps are simple:
Create a new crate and add interpolate = "0.1.2"
as depencency to Cargo.toml, then cargo build --target=wasm32-unknown-unknown
.
I'm getting
error: cannot produce proc-macro for
interpolate v0.1.2
as the targetwasm32-unknown-unknown
does not support these crate types
So far I haven't found a way around this. It seems that proc_macros (which this crate is) just aren't supported in wasm. I haven't done enough digging to understand when/if that will change.
@anowell It seems to work now: https://github.com/rust-lang/rust/issues/52707
I want to use this crate in my yew frontend, but I'm getting:
:(
Any idea how to get it to work?
I found this issue: https://github.com/rust-lang/rust/issues/52707 But it seems to be only about crates that depend on the
proc-macro
crate (?)