deniz.in

Markets

Weather

Loading weather

· via Hacker News – Front Page (native)

Rust 1.100 stabilizes the never type, custom allocators, and Cargo unused-dependency warnings

Rust 1.100.0 ships the never type after a decade of failed attempts, core custom-allocator support for Vec and Box, a DropGuard helper, and new Cargo warnings for unused dependencies.

Rust 1.100 stabilizes the never type, custom allocators, and Cargo unused-dependency warnings

The Rust team has shipped version 1.100.0 of the language, headlined by the stabilization of the never type after roughly a decade of work. According to the Rust Blog announcement published on November 12, users on the stable toolchain can pick the release up via rustup, and the post encourages developers to try the beta or nightly channels if they want to help test future versions.

The never type is stable at last

The never type, written ! in source code, is the language's designated uninhabited type: it describes expressions that never resolve to a value, such as return, break, or std::process::exit. The Rust Blog says it took ten years and five failed stabilization attempts to land.

Because no value of this type can exist, the compiler will coerce ! into any other type, which is what lets one arm of a match diverge while the others produce values. That behavior has long been observable, and functions could already declare -> !. What is new is that the type can be named anywhere — for example in a signature like Result<T, !> to mark an operation that cannot fail. On top of that, Infallible now becomes an alias for !, which makes older APIs built around Infallible compatible with the never type.

That alias required a breaking change: the never type fallback switches from () to ! in the 2015, 2018 and 2021 editions, matching what edition 2024 already did. The team expects the impact to be barely noticeable, but edge cases exist — for instance code that ignores the result of a function returning a generic parameter — and the compiler may now mark more code as unreachable. Compatibility warnings were issued well in advance and fixes were published for affected public crates, so the recommendation is to update dependencies that fail to build rather than pin them.

Custom allocators for Vec and Box

The core parts of the allocator_api feature are now stable, giving library authors the ability to define custom allocators through the newly stabilized Allocator trait and use them with Vec and Box. The Rust Blog presents this as the groundwork for the broader Allocators 1.0 effort: more collections and pointer types should support custom allocators as the API surface expands.

DropGuard for cleanup on every exit path

A new helper, core::mem::DropGuard, runs a closure when it goes out of scope — on every exit path, including early returns, error propagation with ?, and panics. The guard wraps a value, dereferences to it so the value can be used normally, and consumes it when the closure runs. A dismiss method hands the value back without invoking the closure, which the announcement highlights as a building block for transaction-style logic that either fully applies or rolls back; its example reverts mutations to a vector when parsing fails partway through.

A canonical way to create zero-sized values

std::mem::conjure_zst offers a single documented way to create a value of a zero-sized type in unsafe code, replacing the various tricks developers relied on before. The function is unsafe because some APIs depend on zero-sized tokens being impossible to construct: the announcement cites PyO3's Python<'py> marker, which stands in for holding Python's global interpreter lock, and conjuring it from nothing would let otherwise safe calls violate that precondition.

Cargo flags unused dependencies

Cargo now warns about dependencies that go unused, enabled by default through the cargo::unused_dependencies lint, and points at the offending line in Cargo.toml with a suggestion to remove the entry. The warning has limits: it only appears when every build target that might use a dependency entry is being built, and dev-dependencies are excluded because there is no way to guarantee all development targets get compiled. The feature is part of a new linting system for Cargo controlled by the [lints.cargo] table in Cargo.toml, which the post says completes a project goal.

The release notes additionally cover reduced Cargo cache collisions, a min-publish-age option, and the usual batch of newly stabilized APIs.

Why it matters

This release bundles several long-running efforts into stable Rust at once. The never type closes a ten-year design question, changes how infallible APIs can be expressed, and introduces the release's one deliberate breaking change — meaning maintainers of large dependency trees may still hit build breaks and should update affected crates. The allocator work sets the direction for embedded, kernel and performance-sensitive code, while DropGuard and conjure_zst address everyday ergonomics. Perhaps most tellingly for the future, the Cargo lint system opens a new extensibility surface for the build tool itself.

  • #rust
  • #programming-languages
  • #cargo
  • #systems-programming
  • #release

Related posts