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

Improve loop and label handling in Rust code

Enhances gccrs's management of control flow loops, breaks, and continues, especially with labels.

This commit refines how gccrs handles control flow within Rust code, focusing on labeled and nested loops. It improves the resolution and compilation of break and continue statements by introducing specific context functions for loop labels and unifying the handling of break labels. The changes also introduce new test cases to cover various loop and label scenarios.

In Details

The gccrs backend introduces new context management within RUST_COMPILE_CONTEXT and CompileExpr to correctly handle loop labels and break/continue statements. This includes functions for inserting and looking up break and continue labels, and managing a stack for end_label. The changes unify the construction of break labels and ensure correct label generation for while and for loops, impacting name resolution context in rust-default-resolver.cc.

For Context
gccrs
The GCC backend for the Rust programming language, enabling Rust code to be compiled by GCC.
break label
A label specifically used to target a break statement, causing execution to exit the nearest enclosing loop or match expression.
continue label
A label specifically used to target a continue statement, causing execution to proceed to the next iteration of the nearest enclosing loop.
Filed Under: rustcompilercontrol flow