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

gccrs: Add array to slice unsized coercion support

Compiler now supports coercing arrays to slices, enabling more flexible type conversions.

This patch adds support for unsized coercions from arrays to slices in the GCC Rust front-end. Previously, only dynamic trait coercions were handled, and array-to-slice conversions were rejected. The compiler now correctly identifies and tags valid array-to-slice coercions, improving type compatibility.

In Details

The gccrs type checker now handles the unsized coercion from [T; N] to [T]. This is implemented in TypeCoercionRules::coerce_unsized by adding a new case that recognizes array types and their corresponding slice types, emitting an Adjustment::UNSIZE tag when applicable. This complements existing support for dyn Trait coercions.

For Context
unsized coercion
A type conversion in Rust that results in a type with an unknown size at compile time, such as a slice or a trait object. These are handled through specific compiler mechanisms.
Adjustment::UNSIZE
An internal compiler tag or enumeration value used within GCC's Rust front-end to signify that a type adjustment involves an unsized type.
Filed Under: gccrsrustcoerciontype system