dtolnay / watt

Runtime for executing procedural macros as WebAssembly
Apache License 2.0
1.29k stars 29 forks source link

Demo build failing + Example module decode error #54

Open wbrickner opened 10 months ago

wbrickner commented 10 months ago

Would love to write macros using watt, it's very exciting. Can't get anything to work unfortunately, following the demo or the example pattern in the readme.

Demo broken

watt/demo/impl on  master is 📦 v0.0.0 via 🦀 v1.75.0 
❯ cargo build --release --target wasm32-unknown-unknown
    Updating crates.io index
   Compiling proc-macro2 v1.0.75 (/Users/wbrickner/Downloads/watt/proc-macro)
   Compiling unicode-ident v1.0.12
   Compiling quote v1.0.35
   Compiling syn v2.0.48
error[E0277]: `proc_macro2::LexError` doesn't implement `std::fmt::Display`
   --> /Users/wbrickner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/syn-2.0.48/src/error.rs:407:32
    |
407 |         Error::new(err.span(), err)
    |         ----------             ^^^ `proc_macro2::LexError` cannot be formatted with the default formatter
    |         |
    |         required by a bound introduced by this call
    |
    = help: the trait `std::fmt::Display` is not implemented for `proc_macro2::LexError`
    = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
note: required by a bound in `error::Error::new`
   --> /Users/wbrickner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/syn-2.0.48/src/error.rs:158:19
    |
158 |     pub fn new<T: Display>(span: Span, message: T) -> Self {
    |                   ^^^^^^^ required by this bound in `Error::new`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `syn` (lib) due to previous error

Example Code

Following the guide in the readme exactly, I get the wasm to build, but then at the invocation site of the shim (my_macro!()) I get a panic with a module decode error. This originates in the shim, on WasmMacro::new.

ts_test on  master [?] is 📦 v0.1.0 via 🦀 v1.75.0 
❯ cargo check
   Compiling type_set v0.1.0 (/Users/wbrickner/Documents/Projects/type_set/new/type_set)
    Checking ts_test v0.1.0 (/Users/wbrickner/Documents/Projects/type_set/new/ts_test)
error: proc macro panicked
 --> src/main.rs:3:1
  |
3 | the_macro!();
  | ^^^^^^^^^^^^
  |
  = help: message: called `Result::unwrap()` on an `Err` value: DecodeModuleFailed

error: could not compile `ts_test` (bin "ts_test") due to previous error

Thank for all the work you guys are doing for the ecosystem, it's amazing!