Consider an AST validation function/pass to assist with debugging user-defined macros #15819
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-plugins
Area: compiler plugins, doc.rust-lang.org/nightly/unstable-book/language-features/plugin.html
A-syntaxext
Area: Syntax extensions
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
There's a variety of invariants in the AST, e.g. the
Expr
in aPatLit
should (AFAIK) be anExprLit
, and theOption<Expr>
in anExprIf
should be either aExprBlock
orExprIf
. It would be convenient if the compiler either had a AST validation pass run after macro expansion (could include verifying that there are no macros left in the AST), a validation function called on the resulting AST after each macro is expanded or just a series of manual functions that syntax extension authors can call on the code they generate to help debugging.(The first two should, IMO, be opt-in, since most users won't want to be wasting the compilation time on something that should never trigger if they're not writing their own macros.)
The text was updated successfully, but these errors were encountered: