Skip to content

Consider an AST validation function/pass to assist with debugging user-defined macros #15819

@huonw

Description

@huonw

There's a variety of invariants in the AST, e.g. the Expr in a PatLit should (AFAIK) be an ExprLit, and the Option<Expr> in an ExprIf should be either a ExprBlock or ExprIf. 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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-pluginsArea: compiler plugins, doc.rust-lang.org/nightly/unstable-book/language-features/plugin.htmlA-syntaxextArea: Syntax extensionsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions