Stream: wasmtime

Topic: debugging proc macros


view this post on Zulip Dan Gohman (Mar 25 2020 at 13:36):

@Jakub Konka Do you know if there's a way to figure out where errors inside of proc macros are coming from?

view this post on Zulip Dan Gohman (Mar 25 2020 at 13:36):

I'm experimenting with some changes, and I have an error like this:

view this post on Zulip Dan Gohman (Mar 25 2020 at 13:36):

error[E0308]: mismatched types
 --> crates/wasi-common/src/wasi.rs:6:1
  |
6 | / wiggle::from_witx!({
7 | |     witx: ["wig/WASI/phases/snapshot/witx/wasi_snapshot_preview1.witx"],
8 | |     ctx: WasiCtx,
9 | | });
  | |   ^
  | |   |
  | |___expected `usize`, found `i32`
  |     in this macro invocation
  |
help: you can convert an `i32` to `usize` and panic if the converted value wouldn't fit
  |
6 | wiggle::from_witx!({
7 |     witx: ["wig/WASI/phases/snapshot/witx/wasi_snapshot_preview1.witx"],
8 |     ctx: WasiCtx,
9 | });.try_into().unwrap()

view this post on Zulip Dan Gohman (Mar 25 2020 at 13:38):

I can use cargo expand, but then I get the whole from_witx expansion and no indication of where the error is

view this post on Zulip Dan Gohman (Mar 25 2020 at 13:38):

And rustc's help message isn't so helpful here :o}

view this post on Zulip Jakub Konka (Mar 25 2020 at 13:41):

Yeah, currently tracking errors is pretty hard and messages don't tell anything meaningful at all. I'm not an expert in this but I guess in the future we should probably invest into some error tracking like in wasm-bindgen (if at all possible).

view this post on Zulip Jakub Konka (Mar 25 2020 at 13:41):

All I can recommend right now is to use cargo expand

view this post on Zulip Jakub Konka (Mar 25 2020 at 13:41):

which is less than ideal

view this post on Zulip Pat Hickey (Mar 25 2020 at 17:38):

debugging proc macros is unfortunately very difficult :(

view this post on Zulip Pat Hickey (Mar 25 2020 at 17:39):

there are a lot of smaller test cases in the crates/wiggle/tests directory, i would try to reproduce your error there

view this post on Zulip Pat Hickey (Mar 25 2020 at 17:39):

so that the expansion is a little smaller


Last updated: Nov 22 2024 at 16:03 UTC