gccrs: Add AST support for Rust trait aliases
gccrs introduces Abstract Syntax Tree (AST) support for Rust's unstable trait aliases feature.
gccrs now supports handling Rust’s trait aliases at the Abstract Syntax Tree (AST) level, up to the lowering phase. Although trait aliases are an unstable feature in current Rustc versions, they are available in older versions (pre-1.49) and were adopted by the Rust core library between versions 1.51 and 1.54. This commit adds the necessary AST nodes, visitor patterns, and parsing logic to recognize and process trait aliases.
In Details
The gccrs frontend has incorporated support for trait aliases in its Abstract Syntax Tree (AST) representation. This includes adding new AST node types (Item::Kind::TraitAlias, TraitAlias class), visitor methods (ASTVisitor::visit (TraitAlias)), and integrating trait alias parsing into Parser::parse_trait. Feature gating for trait aliases is also handled via FeatureGate::visit (TraitAlias). Support extends through AST collection, resolution, and lowering, with trait aliases stubbed out in ASTLoweringItem for now. This work enables gccrs to correctly parse and represent code that…
- Abstract Syntax Tree (AST)
- A tree representation of the abstract syntactic structure of source code. The compiler builds an AST after parsing to represent the code's structure before performing semantic analysis and transformations.
- trait alias
- A Rust language feature that allows creating a new name (an alias) for a specific combination of traits. It simplifies the use of complex trait bounds.
- lowering
- A compiler phase where higher-level intermediate representations are transformed into lower-level ones, getting closer to machine code. In Rust, this involves converting the HIR (High-level Intermediate Representation) into a form more suitable for backend code generation.
- feature gate
- A mechanism in Rust (and by extension, gccrs) to control access to unstable or experimental language features. Features must be explicitly enabled, usually via an attribute, to be used.