There is a rule that a macro can parse everything only once using parsing rules like expr
or pat
, etc. This means that an 1+1
expr, after having been assigned to an $e:expr
metavariable once cannot be split up into 3 tokens again. In particular you also, AFAIK, cannot try to parse tokens into something different after parsing them as expr
failed. Edit: Little test reveals that it is more like: you cannot try to parse a sequence of tokens into something different after parsing them as expr
failed and that parsing attempt already consumed at least one token.
Also, in a sense this expr parsing does give it parantheses-like wrapping, for example you won’t make any mistake by putting an $e:expr
into an expression like $e * 5
, a huge footgun in C macros if you forget parantheses. I suspect that trace_macros
might give confusing/misleading outputs, too, if you do something like $e * 5
with $e
being 1+1
.
My best guess is that the reason that tt
still accepts an already-parsed expression is that you’d still want to be able to use $($token:tt)*
as a way to say I don’t care, I’ll accept anything here.