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

gccrs: Add flag to unify of expect never

Compiler gains a flag to unify 'expect never' behavior in type coercion.

A new flag has been added to gccrs to unify the behavior of ‘expect never’ during type coercion. This change affects multiple functions within rust-coercion.cc and rust-unify.cc, introducing a consistent way to handle scenarios where a type is expected to be never. This aims to resolve issues related to type coercion and unification, as indicated by the fix for Rust-GCC/gccrs#4918.

In Details

This commit introduces a flag to gccrs that unifies the handling of the expect_never rule across various type unification and coercion routines. Functions like TypeCoercionRules::TryCoerce, UnifyRules::Resolve, and UnifyRules::expect_never are modified to respect this new flag. This change standardizes how the compiler treats types that are expected to be uninhabited (never), ensuring consistent behavior during type checking and coercion operations.

For Context
Type Coercion
The automatic conversion of one type into another by the compiler. In Rust, this happens in specific contexts, like converting between numeric types or calling methods.
Unification
A process in type systems where two types are compared, and constraints are derived to make them compatible or to determine if they are equivalent. It's fundamental to type inference and checking.
expect never
A specific rule or behavior within the Rust type system (and implemented in gccrs) where the compiler anticipates a type that is definitively uninhabited (the 'never' type, !).
Filed Under: gccrsrusttype systemcompiler flags