Description
#69211 simplified parsing and fixed treatment of $
tokens coming from proc macros, but slightly regressed diagnostics.
If a declarative macro body contains something that looks like an unknown macro variable $ var
, then it's preserved and outputted like two-token sequence punctuation $
and identifier var
.
We previously tried to detect such sequences in Parser::bump
, but the detection wasn't correct and wasn't done in the best way for recovery.
Instead, we need to support parsing the $ IDENT
sequences in context dependent fashion, as an error expression in expression position, as an error type in type position etc.
Currently supported positions for macro variables (roughly in the order of importance):
-
expr
-
ty
-
pat
-
item
-
ident
-
lifetime
-
vis
-
path
-
block
-
literal
-
meta
-
stmt
It's quite possible that implementing this recovery for ident
can successfully make implementing it for expr
, ty
, pat
, path
and meta
unnecessary.