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

gccrs: Fix missing error diag on const parser and crash in typecheck

Fixes parsing and type-checking errors in gccrs related to constant expressions.

This commit addresses two critical issues in gccrs: a missing error diagnostic during the parsing of constant expressions and a crash during type checking when evaluating constants. The fix ensures that the parser correctly handles default expressions by forcing braces, and that the type checker can safely evaluate constants even when type checking fails, preventing crashes caused by invalid error nodes. This resolves Rust-GCC/gccrs#4173.

In Details

This change in gccrs targets issues in rust-parse-impl.hxx and rust-hir-type-check-base.cc. It ensures that the parser properly handles default expressions in impl blocks by forcing braces, which is necessary for correct constant evaluation. Additionally, it prevents crashes in the type checker during const eval when type checking fails by ensuring that invalid error nodes do not propagate, thereby fixing issues like Rust-GCC/gccrs#4173.

For Context
error diag
Diagnostic message generated by the compiler to report an error to the user. 'Diag' is short for 'diagnostic'.
const parser
The component of the Rust compiler frontend responsible for parsing syntax related to constant expressions or compile-time evaluated values.
typecheck
The process of verifying that the types used in a program are consistent and adhere to the language's rules. This is a crucial phase in compilation.
const eval
Constant evaluation, where the compiler computes the value of an expression at compile time.
Filed Under: gccrsparsingtype checkingconstantsrust