I'm trying to debug spans in a procedural macro. -Zunpretty=expanded
doesn't show span information. Is there an easy way to see what spans are attached to tokens?
Assuming you're using proc_macro2 which is alternative to the compiler's proc_macro
crate, a TokenStream
can be converted into an iterator over TokenTree
s from which you can access the span. Note that for methods like token_tree.span().start() to be meaningful, you'll need to compile with the span-locations
feature and use the nightly toolchain.
Here's a related reply I made in a separate thread for additional context.
Thanks, that works for me. Is there no option in rustc
to dump that information then?
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.