GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gccrs

gccrs: lower: Use enum instead of bool for checking for valid impl Trait params

Refactors impl Trait parameter checking in gccrs's AST lowering to use an enum.

This commit refactors the implementation of impl Trait parameter checking in gccrs’s AST lowering phase. Previously, a boolean flag was used to determine the validity of impl Trait parameters in function arguments. This change replaces the boolean with a more descriptive enum class, improving code clarity and maintainability. The affected AST lowering functions have been updated to use the new enum API.

In Details

The refactoring involves changes in hir/rust-ast-lower-type.h to introduce a new enum for representing the state of impl Trait checks, and updates to functions like ASTLowerImplItem::visit and ASTLoweringType::translate across several .cc files. This change moves away from a simple boolean check towards a more explicit state representation, likely differentiating between cases like 'not an impl Trait', 'valid impl Trait', or 'invalid impl Trait', leading to potentially clearer logic in the lowering pipeline.

For Context
impl Trait
A Rust feature that allows function return types or parameter types to be specified as implementing a particular trait, without naming the concrete type. This helps in simplifying complex generic signatures.
AST Lowering
The process of converting the Abstract Syntax Tree (AST), which represents the source code structure, into a lower-level intermediate representation (IR), such as the High-Level IR (HIR) in gccrs. This prepares the code for subsequent compiler phases like optimization and code generation.
enum class
A scoped enumeration type in C++ that provides stronger type safety and avoids polluting the global namespace compared to traditional C-style enums.
parameter
An input to a function or method. In this context, it refers to function arguments that use the impl Trait syntax.
Filed Under: gccrsrustloweringimpl traitcompiler