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

gccrs: Implements shim for legacy const generics attribute

gccrs adds a workaround for Rust's `#[rustc_legacy_const_generics]` attribute to support older code patterns.

This commit introduces a workaround in gccrs for Rust’s #[rustc_legacy_const_generics] attribute, which is necessary for compiling certain parts of stdarch. This attribute is a legacy feature used to enable const generics in older Rust code. The implemented shim provides a starting point for handling these constructs, although it doesn’t fully implement the attribute’s behavior. The change adjusts type cast rules and adds related attributes.

In Details

gccrs implements a shim for the #[rustc_legacy_const_generics] attribute, essential for compiling stdarch. This attribute is a workaround for older Rust versions that lacked full const generics support. The change modifies TypeCastRules::cast_rules and adds the attribute definition. While not a complete implementation, it allows compilation of code using this legacy feature, addressing Rust-GCC/gccrs#3868.

For Context
const generics
A Rust feature allowing generic parameters to be constant values, enabling compile-time computations and more specialized generic code. For example, struct Array<T, const N: usize>.
attribute
In Rust, attributes are metadata attached to code elements (like functions or structs) using #[...] syntax. They control various aspects of compilation, behavior, or code generation.
shim
A piece of code that acts as an intermediary or workaround to enable compatibility between different systems or software versions. In this context, it bridges a gap in gccrs's support for an older Rust feature.
stdarch
A Rust crate providing low-level, architecture-specific intrinsics and primitives, often used for performance-critical code and SIMD operations.
Filed Under: gccrsrustconst-genericscompatstdarch