GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gccrs

gccrs: Reject type param defaults using later params

Compiler now rejects Rust type parameter defaults that reference parameters declared later in the sequence.

The gccrs compiler has been updated to reject invalid Rust type parameter defaults. Previously, it only caught cases where a default referred to its own parameter; now, it also flags defaults that reference parameters declared later in the generic parameter list. This prevents potentially erroneous type definitions and improves compile-time error checking for generic types.

In Details

The ForeverStack::forward_declared check in rust-forever-stack.h has been enhanced to detect type parameter defaults that reference parameters appearing later in the declaration sequence, in addition to self-referential defaults. The resolve_type_path_like function in rust-late-name-resolver-2.0.cc is updated to skip this check for Self, as it's a special case. This addresses a gap in compile-time validation for generic Rust types.

For Context
gccrs
The GCC frontend for the Rust programming language.
Type Parameter
In generic programming, a placeholder for a type that is specified when a generic type or function is used. In Rust, these are often denoted by angle brackets like <T>.
Default
A pre-defined value or type that is used for a type parameter if no specific type is provided when the generic is instantiated. For example, struct Foo<T = i32>.
Self
A special type keyword in Rust that refers to the type the current impl block is for. It is distinct from other generic type parameters.
Filed Under: gccrsrustgeneric programmingcompiler