FRIDAY, JULY 17, 2026
gccrs
gccrs: Implement 'unsize' lang item
The 'unsize' language item is now implemented in the GCC Rust front-end.
This patch introduces the ‘unsize’ language item to the GCC Rust compiler. This item is crucial for handling unsized types, enabling features like array-to-slice coercions by providing a way for types to express their relationship with unsized counterparts.
In Details
The Rust language item system in gccrs is extended with the UNSIZE kind, and the BaseType::unsize_to function is added to rust-tyty.cc. This function will be used by coercion rules to determine if a type can be coerced to another, specifically targeting unsized types. This lays the groundwork for implementing various unsized coercion scenarios.
For Context
- lang item
- A special item in the Rust compiler that represents fundamental language concepts or traits, such as the
SizedorCopytraits, or operations likeunsize. - unsized type
- A type whose size cannot be determined at compile time, such as slices (
[T]) and trait objects (dyn Trait). These types must be handled via pointers or references.