Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser: Implement recovery for potential unknown macro variables $ IDENT #69229

Open
12 tasks
petrochenkov opened this issue Feb 17, 2020 · 0 comments
Open
12 tasks
Assignees
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.

Comments

@petrochenkov
Copy link
Contributor

#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.

@Centril Centril added A-parser Area: The parsing of Rust source code to an AST T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Feb 17, 2020
@petrochenkov petrochenkov self-assigned this Mar 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

2 participants