something I just ran into - the wiggle
proc macro that i'm working on with @kubkon, as an eventual replacement for wig
, needs to be rerun if the witx file it reads in changes.
the suggested solution here is to use include_str
https://users.rust-lang.org/t/equivalent-of-cargo-rerun-if-changed-for-procedural-macros/37036 - however I cant rewrite the file loading logic in terms of include_str
because witx contains use
directives that point to other files.
is this issue on the radar for cargo / rustc teams? @Alex Crichton @Josh Triplett
and on the same lines - is any work underway on making proc macro error messages show the actual tokens that caused it? basically my workflow now is to get an error out of cargo build
and then go hunting through cargo expand
's output to guess what may have caused it
@Pat Hickey this isn't currently on the radar, no, unfortunately
currently if the tokens are purely synthesized by a macro I don't think there's a way to get spans to point at those tokens
but calling .to_string().parse() may be a lil better, in general debugging proc macros isn't a great experience :(
the sol'n for rerunning would actually probably be on the rustc side of things, a function in the proc_macro
crate itself most likely
(or something like that)
i read something in the cargo expand docs that basically said that the string repr it gives is lossy, and may not even show the same error
that is true yeah, primarily b/c of hygiene I believe
although there may be other subtelties I'm forgetting
yeah its probably something like that but i dont fully understand the hygiene story... this is my first time really using proc macros
unforutnately I don't know a great workaround for the "rerun on witx file change"
and yeah the debug experience is less than great presently. not quite bad enough to switch to just printing a syntax tree... but not great
other than having the proc-macro also have a build script which prints the various directives
you can typically fiddle around with spans enough to get user input to show the right errors
but not afaik for code synthesized by the macro tiself
right
well, ill keep at it for now
too many things on my plate to take any side tracks into rustc to see if i can make the debug experience better
Last updated: Dec 23 2024 at 12:05 UTC