Description
I noticed that this question from @Stebalien was left unaddressed in the compile_error!
RFC:
Is the span information not attached to the tokens passed to a macro? I'd like to be able point out which token in the macro input caused the macro expansion to fail (and why).
Before compile_error!
was a thing, I generally report errors to the user (where possible) by passing the offending token to a "sink" macro that has no possible matches, which would cause the compiler to report no rule expected the token <token>
with the right span. It is nice that now I can specify a useful message, however we lost the ability to point the error back to the right span. It is unfortunate to have to make this trade-off (either providing the right span without telling you why, or telling you why without reporting where), and in some scenario neither of the two options on their own would be sufficient to understand the error (it could be a very generic error that could happen in a lot of places – think "missing a semicolon" or "unbalanced braces" kind of errors).
cc @sgrif