« All posts

Rust's Never Type Finally Reaches Stable After Two Years of Work

Rust stabilizes its never (!) type after two years, resolving tricky type-inference edge cases while preserving backward compatibility.

Rust compiler contributor 'waffle' has stabilized the language's never type (!), which marks functions that never return, after more than two years of effort. The type enables the compiler to eliminate dead code around infallible operations—such as string conversions that can't fail—and simplifies type inference for constructs like infinite loops.

The hardest part of the work involved a subtle interaction: the never type's implicit conversion to other types could leave the compiler unable to infer a concrete type in certain closures. Rust's 2024 edition changed the fallback type used in these ambiguous cases from the unit type to the never type itself, a technically breaking change that needed backporting to older editions. Simultaneously, the standard library's Infallible type was set to become a type alias for !, which was also a breaking change on its own.

Because the two changes largely cancel each other out, most existing code should continue to compile without modification. Still, the Rust team used the 'crater' tool—which compiles every public crate on crates.io—to validate the change at scale, illustrating how seriously the ecosystem treats backward compatibility even for long-awaited language features.

This synthesis was produced from its source by AI; there is no human editor or manual review step. How we work