GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
gccrs

gccrs: Add lang owned_box and box expression support

gccrs now supports the `owned_box` lang item and `box` expressions.

This commit introduces support for Rust’s owned_box language item and box expressions in the gccrs compiler. It involves significant changes across AST, backend compilation, and various checking passes to correctly lower and process these features.

In Details

The BoxExpr lowering is implemented in rust-compile-expr.cc, utilizing exchange_malloc and constructor expressions. The owned_box feature is integrated into FieldAccessExpr and DereferenceExpr, with adjustments in HIRCompileBase::resolve_deref_adjustment. This impacts the code generation and type checking for heap-allocated types in Rust.

For Context
owned_box
A language feature in Rust that allows for heap-allocated data with unique ownership.
box expression
Rust syntax for creating a boxed value, allocating it on the heap.
AST
Abstract Syntax Tree. A tree representation of the abstract syntactic structure of source code.
Lowering
The process of transforming code from a higher-level representation (like AST) to a lower-level one (like HIR or machine code).
HIR
High-level Intermediate Representation. An intermediate representation of code used within the compiler, typically after parsing but before optimization or backend-specific code generation.
Filed Under: gccrslanguage-featurebackendcodegen