parser: Implement recovery for potential unknown macro variables $ IDENT
#69229
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The parsing of Rust source code to an AST
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
#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 identifiervar
.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 forexpr
,ty
,pat
,path
andmeta
unnecessary.The text was updated successfully, but these errors were encountered: