Skip to content

Commit 356027b

Browse files
committed
ast_passes/validation: update module docs
- Syntax extensions are replaced by proc macros. - Add rationale for why AST validation pass need to be run post-expansion and why the pass is needed in the first place.
1 parent 6c6b302 commit 356027b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

compiler/rustc_ast_passes/src/ast_validation.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
// Validate AST before lowering it to HIR.
2-
//
3-
// This pass is supposed to catch things that fit into AST data structures,
4-
// but not permitted by the language. It runs after expansion when AST is frozen,
5-
// so it can check for erroneous constructions produced by syntax extensions.
6-
// This pass is supposed to perform only simple checks not requiring name resolution
7-
// or type checking or some other kind of complex analysis.
1+
//! Validate AST before lowering it to HIR.
2+
//!
3+
//! This pass intends to check that the constructed AST is *syntactically valid* to allow the rest
4+
//! of the compiler to assume that the AST is valid. These checks cannot be performed during parsing
5+
//! because attribute macros are allowed to accept certain pieces of invalid syntax such as `async
6+
//! fn` within a trait (before async-fn-in-trait was introduced).
7+
//!
8+
//! These checks are run post-expansion, after AST is frozen, to be able to check for erroneous
9+
//! constructions produced by proc macros. This pass is only intended for simple checks that do not
10+
//! require name resolution or type checking, or other kinds of complex analysis.
811
912
use itertools::{Either, Itertools};
1013
use rustc_ast::ptr::P;

0 commit comments

Comments
 (0)