Rust's Never Type Finally Stabilized After Two Years

Original: Stabilizing Rust's Never Type

Why This Matters

Stable never type unlocks cleaner generic APIs and better compiler optimizations for all Rust codebases.

On August 24, 2026, Rust compiler contributor 'waffle' stabilized the never type (!), a feature marking functions that never return. After over two years of work, the change landed despite involving a minor breaking change to earlier Rust editions, requiring careful validation against real-world code.

Rust's never type, written as !, has existed inside the compiler for years but remained an unstable feature unavailable to ordinary Rust programmers. That changed on August 24, 2026, when contributor 'waffle' completed the stabilization work.

The never type serves two purposes. Practically, it enables more efficient generic code. The standard library's FromStr trait, for instance, requires an associated error type—but some conversions are infallible. Setting that error type to ! tells the compiler the error branch can never exist, allowing it to eliminate that dead code entirely. Philosophically, it gives the type system a uniform way to handle expressions that never produce a value, such as infinite loops, simplifying type inference without special-casing.

The never type has one distinctive property: it automatically coerces to any other type. This is safe because if code claims to hold a never-type value, the compiler knows that code path is unreachable, making the coercion harmless and useful for dead-code elimination.

Stabilization took two-plus years partly because of a subtle breaking change affecting older Rust editions—specifically around 'never fallback,' a corner case in how the compiler resolves ambiguous type inference involving !. The team had to verify the impact on real code before proceeding.

Source

lwn.net — Read original →