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

gccrs: Reject multiple move sources in product-type expressions

gccrs now prevents moving values from the same product-type expression more than once.

This commit enhances gccrs’s borrow checker by preventing multiple moves from the same product-type expression (like structs or tuples). It achieves this by passing the expression’s HIR ID through the BIR, allowing the analysis to identify and reject attempts to move from the same source multiple times. A new test case validates this behavior.

In Details

The BIR builder in gccrs now propagates the HIR expression ID for struct expressions when moves occur. This enables the borrow checker, specifically the drop analysis component, to track if a single expression has already been used as a move source. The move_all function within AbstractBuilder is updated to reject such scenarios, preventing double-moves and upholding Rust's ownership rules. This change refines the analysis of move operations in the backend intermediate representation.

For Context
Product Type
A composite data type formed by combining other types. In Rust, structs and tuples are examples of product types.
Move
In Rust, moving a value transfers ownership of that value to another variable. After a move, the original variable is no longer valid and cannot be used.
Borrow checker
A part of the Rust compiler that enforces the rules of ownership, borrowing, and lifetimes to prevent memory safety issues at compile time.
BIR
Backend Intermediate Representation. A lower-level intermediate representation used by gccrs after the initial HIR, closer to machine code, for backend-specific analysis and transformations.
HIR
High-level Intermediate Representation. A representation of the code that is closer to the source language than machine code, used by the Rust compiler (and gccrs) for analysis and transformations before generating lower-level code.
Filed Under: gccrsrustborrow checkercompiler