4
lorentz
19d

So fun fact! The Rust macro error

"Macro expansion ignores <token> and everything after it"

does NOT mean that macro expansion on general ignores this token. What it DOES mean is that the macro expanded to something, then the parser was invoked, and the parser stopped consuming tokens at the specified point.

In normal human speak, this means
"This token is invalid in its context after macro expansion. Refer to the generated code for concrete error."

I spent hours moving intermediate results into macro parameters because I thought the error meant that your macro cannot expand to the second half of a comma-separated list or whatever, until I got the same message about '(' which is very obviously permitted macro output and doesn't even really make sense given that it's not a token.

Comments
  • 3
    macro errors are so confusing and also easily break everything and the error isn't even in the right place

    it's like I'm playing Russian roulette
  • 3
    @jestdotty or like you could call it: "A me roulette"
Add Comment