When reporting errors in macros like println!
Rust compiler shows the precise location within the format string where something has gone wrong, e.g.:
11 | println!("I'm going to substitute {foo}... or not");
| ^^^^^ not found in this scope
How I do the same thing for my format!
-like macro? Both ways of reporting errors in procedural macro (quote_spanned!
+ compile_error!
or the experimental Diagnostic
API) rely on proc_macro::Span
and I don't see a way to construct a Span
for a location inside a token, even via experimental APIs.