Skip to main content

Module ast_validation

Module ast_validation 

Source
Expand description

Validate AST before lowering it to HIR.

This pass intends to check that the constructed AST is syntactically valid to allow the rest of the compiler to assume that the AST is valid. These checks cannot be performed during parsing because attribute macros are allowed to accept certain pieces of invalid syntax such as a function without body outside of a trait definition:

โ“˜
#[my_attribute]
mod foo {
    fn missing_body();
}

These checks are run post-expansion, after AST is frozen, to be able to check for erroneous constructions produced by proc macros. This pass is only intended for simple checks that do not require name resolution or type checking, or other kinds of complex analysis.

Structsยง

AstValidator ๐Ÿ”’

Enumsยง

AllowDefault ๐Ÿ”’
AllowFinal ๐Ÿ”’
SelfSemantic ๐Ÿ”’
Is self allowed semantically as the first parameter in an FnDecl?
TraitOrImpl ๐Ÿ”’

Functionsยง

check_crate
validate_generic_param_order ๐Ÿ”’
Checks that generic parameters are in the correct order, which is lifetimes, then types and then consts. (<'a, T, const N: usize>)