]> git.proxmox.com Git - rustc.git/blame - src/doc/rustc-dev-guide/src/ast-validation.md
bump version to 1.81.0+dfsg1-2~bpo12+pve1
[rustc.git] / src / doc / rustc-dev-guide / src / ast-validation.md
CommitLineData
ba9703b0
XL
1# AST Validation
2
9ffffee4
FG
3_AST validation_ is a separate AST pass that visits each
4item in the tree and performs simple checks. This pass
5doesn't perform any complex analysis, type checking or
6name resolution.
7
8Before performing any validation, the compiler first expands
9the macros. Then this pass performs validations to check
10that each AST item is in the correct state. And when this pass
11is done, the compiler runs the crate resolution pass.
12
13## Validations
14
15Validations are defined in `AstValidator` type, which
16itself is located in `rustc_ast_passes` crate. This
17type implements various simple checks which emit errors
18when certain language rules are broken.
19
20In addition, `AstValidator` implements `Visitor` trait
21that defines how to visit AST items (which can be functions,
22traits, enums, etc).
23
24For each item, visitor performs specific checks. For
25example, when visiting a function declaration,
26`AstValidator` checks that the function has:
27
28* no more than `u16::MAX` parameters;
29* c-variadic functions are declared with at least one named argument;
30* c-variadic argument goes the last in the declaration;
31* documentation comments aren't applied to function parameters;
32* and other validations.