Rust 1.100.0 finally stabilizes the never type, adds custom allocators, and ships Cargo dependency cooldowns
Tempered into gold! Rust 1.100.0 officially released
Sorry, everyone, this is a belated piece of news: Rust 1.100.0 was released on November 12, but it contains a lot of very practical language updates that I couldn't resist sharing.
First, let me emphasize: Rust is a programming language that empowers everyone to build reliable and efficient software, and I hope more and more developers will join in building software with Rust.
If you've installed Rust via rustup, use the following command to update to the latest stable version:
$ rustup update stable
If you haven't installed rustup yet, you can get it on the corresponding page of the official website.
If you want to test future Rust versions, consider switching your local toolchain to the beta channel (rustup default beta) or nightly channel (rustup default nightly).
Enough talk, let's get straight to the point!
The never type
After 10 years and five failed stabilization attempts, the never type is finally stable!
The never type is written as ! in code, and it has no constructible values.
It represents expressions that never return a value normally. Expressions like return, break, std::process::exit transfer or terminate control flow, and their type is !.
If you have Kotlin experience, this is similar to Kotlin's Nothing type.
Where a certain type is expected, Rust allows ! to be implicitly coerced to that type. For example, a branch in match or if can return no value:
fn mrrrow(option: Option<u32>) {
let value = match option {
// The type of `x` is `u32`
Some(x) => x,
// The type of `return` is `!`, coerced to `u32`,
// so the whole `match` passes type checking.
None => return,
};
// ...
}
Previously, ! could already be used this way, and could appear as a function return type (-> !), but its positions were limited. After 1.100.0, it can be written anywhere a type is expected:
fn infallible_unwrap<T>(res: Result<T, !>) -> T {
// ^^ Previously, `Result<_, !>` was not allowed
let Ok(v) = res;
v
}
In addition, 1.100.0 makes Infallible an alias for the never type. APIs that previously used Infallible to represent infallibility can now use ! for the same type. Turning Infallible into an alias has been part of the plan since it was introduced, which is one reason never type stabilization was so difficult.
To turn Infallible into an alias, 1.100.0 introduces a breaking change. In editions prior to 2024 (2015, 2018, 2021), when ! needs an implicit coercion and the target type cannot be inferred from context, the compiler now falls back to !. These editions previously fell back to (), while edition 2024 already used !. Most code will be unaffected, but if f() returns Result<T, E> and f()?; discards the Ok value, code that previously relied on the () fallback to infer T may fail to compile. This change may also cause the compiler to treat more code as unreachable.
To minimize the impact of this breaking change, future-compatibility warnings were issued well in advance, and fixes were released for affected public crates. If your dependencies fail to compile because of never type issues, try upgrading first; fixes may already be available.
Allocator API
This release stabilizes the core of allocator_api. Developers can now define custom allocators and use them with certain standard library types, currently Vec and Box. These capabilities are enabled by the newly stabilized Allocator trait.
This is the foundation of the Allocators 1.0 project goal. But it's far from done: the API surface available to custom allocators still needs expansion, and more collections and pointer types await support.
The core trait and design are set, and subsequent stabilizations should go faster.
DropGuard: running a closure on drop
Rust's Drop trait lets a type run code when it is dropped. Destructors run on normal scope exit, return, early ? returns, or when a panic triggers stack unwinding. With panic = "abort", the process terminates directly and destructors are skipped. For example, the standard library's TcpStream closes its connection on drop.
If you just need to do one cleanup when leaving a scope, defining a dedicated type to implement Drop is a bit cumbersome. The new helper type core::mem::DropGuard runs a closure for you on drop.
DropGuard::new takes a value and a closure. The guard implements Deref and DerefMut, so you can access the inner value as usual. When the guard is dropped, it passes the value to the closure.
DropGuard::dismiss takes the value out of the guard, skipping the closure. dismiss is designed as an associated function to avoid conflicting with same-named methods exposed by the inner value through DerefMut. This lets you quickly implement transactional all-or-nothing APIs with automatic rollback. The example below implements a parser that uses a guard to roll back changes on failure:
use std::mem::DropGuard;
use std::num::ParseIntError;
/// Attempts to parse all `strings` and push them into `nums`.
/// If any one fails to parse, `nums` is left unchanged.
fn parse_all(nums: &mut Vec<u32>, strings: &[&str]) -> Result<(), ParseIntError> {
let len = nums.len();
let mut nums = DropGuard::new(nums, move |nums| {
nums.truncate(len); // ← 1. Reset the vec on failure
});
for s in strings {
nums.push(s.parse()?); // ← 2. Once `?` returns an error, trigger rollback
}
DropGuard::dismiss(nums); // ← 3. All parsed successfully, dismiss the guard
Ok(())
}
Constructing zero-sized types from thin air
Rust's unsafe code guidelines are still under discussion. During those discussions, it became clear that what it means to construct a zero-sized type (ZST) unsafely, and the recommended way to write such code, needed to be clarified.
Rust 1.100 answers this with a function: std::mem::conjure_zst.
When you are sure it is safe to construct a particular ZST, you can use this function to create a value, avoiding patterns like transmute from () or MaybeUninit::uninit().assume_init(). A zero-sized type with a value has only one possible value, but constructing and using that value must still honor the type's safety invariants.
That's why this function is unsafe. For example, PyO3's Python<'py> is a zero-sized token representing that the current thread has attached to the Python interpreter. In builds with the global interpreter lock (GIL) enabled, it also represents that the current thread holds the lock. Conjuring this token from thin air could allow safe PyO3 calls to execute when those preconditions are not met.
Cargo reports unused dependencies
Compiling dependencies that are no longer used, or compiling a dependency on a platform where it is not needed, slows down builds.
rustc's unused_crate_dependencies lint works per crate, so it may flag dependencies used by other binary targets in the same package as unused. For example, tracing-subscriber in [dependencies] is visible to every bin in the package, but only some bins may use it.
Cargo now directly reports unused dependencies, for example:
warning: unused dependency `tracing-subscriber`
--> Cargo.toml:23:1
|
23 | tracing-subscriber.workspace = true
| ^^^^^^^^^^^^^^^^^^
|
= note: `cargo::unused_dependencies` is set to `warn` by default
help: consider removing the dependency on `tracing-subscriber`
This warning has a limitation: it only appears when every build target that could use a dependency has been built. For example, running cargo check --bin foo will not report unused dependencies in [dependencies], because some other bin might still use them. Unused dev-dependencies also do not trigger warnings, because there is no way to ensure every development build target has been built.
This warning is part of Cargo's new lint system, controlled by the [lints.cargo] table in Cargo.toml. This release also completes the Cargo lint project goal. Check out the other lints that have been introduced.
Reducing Cargo cache conflicts
Cargo places intermediate build artifacts in build-dir and final artifacts in target-dir. By default, both point to target/ at the workspace root. Different build configurations (such as --features) leave multiple copies of the same library or executable in build-dir. These copies are supposed to be distinguished by a build configuration hash, but platform limitations mean that hash cannot always be applied. This can cause redundant rebuilds, missing rebuilds when they should happen, and confusion about which artifact is actually in use. When multiple git worktrees share one build-dir, these problems are amplified.
Now build-dir applies build configuration hashes consistently to everything: directories are organized by build step rather than by file type, and hashes move from filenames to parent directories.
This work began with the 2025 build directory layout project goal. This stabilization is a milestone toward new project goals and clears the way for future improvements like cache garbage collection, cross-workspace cache deduplication, cross-workspace caching, and fine-grained locking.
Before these changes took effect, the Rust team issued a call for testing. Although this is an internal change, it may break build scripts and tests that wrote workarounds for missing or incomplete functionality. In some cases, those workarounds are no longer needed.
Cargo min-publish-age, a.k.a. dependency cooldowns
Malicious package versions are often detected by automated scanners or the community within hours to days after publication.
Rust 1.100 stabilizes Cargo dependency resolution that is aware of min-publish-age: when selecting versions, Cargo can wait out this window before adopting a newly published version. This is also called dependency cooldowns.
You can enable it in .cargo/config.toml:
[registry]
global-min-publish-age = "3 days"
When resolving new versions, Cargo skips candidates still in the cooldown period and tells you which versions it blocked. Versions already in Cargo.lock can continue to be used.
$ cargo update
Updating crates.io index
Locking 2 packages to highest compatible version as of min-publish-age
Adding cc v1.11.0 (available: v1.18.0, published 3 hours ago)
Adding clap 4.6.7 (available: 4.6.9, published 2 days ago)
If you really need a new version, you can bypass this check for a single update:
$ CARGO_RESOLVER_INCOMPATIBLE_PUBLISH_AGE=allow cargo update clap --precise 4.6.9
Updating crates.io index
Updating clap 4.6.7 -> 4.6.9 (published 2 days ago, minimum age 3 days)
The allowed new version is also written to Cargo.lock until a later update re-resolves that dependency.
A few things to note:
- This relies on the registry recording each version's publish time. Versions whose index entries lack a
pubtimefield will never be blocked. cargo installignores the minimum publish age restriction, both for the installed crate and its dependencies. If needed, pin a version withcargo install [email protected].- Cooldowns can reduce the risk of certain supply chain attacks, but they are not a complete defense on their own. Continue reviewing dependency updates as usual.
Further ecosystem protection work is on the crates.io supply chain hardening project goal, including quarantine support and automatic detection of suspicious versions.
Stable APIs
impl PartialEq<Cow<'_, [U]>> for Vec<T, A>impl PartialEq<Cow<'_, [U]>> for &[T]impl PartialEq<Cow<'_, [U]>> for &mut [T]std::alloc::Allocatorstd::alloc::Globalstd::alloc::Systemimpl Allocator for Globalimpl Allocator for Systemimpl<A: Allocator> Allocator for &Aimpl<T: Allocator, A: Allocator> Allocator for Box<T, A>impl<A: Allocator> Allocator for &mut Aimpl<T: Allocator, A: Allocator> Allocator for Arc<T, A>impl<T: Allocator, A: Allocator> Allocator for Rc<T, A>Box::new_inBox::from_raw_inBox::from_non_null_inBox::into_raw_with_allocatorBox::into_non_null_with_allocatorBox::allocatorVec::new_inVec::with_capacity_inVec::from_raw_parts_inVec::from_parts_inVec::into_raw_parts_with_allocatorVec::into_parts_with_allocatorVec::allocatorChild::main_thread_handleimpl Default for std::sync::Oncebool::toggleBox::takeBox::mapRc::mapArc::mapimpl AsRef<T> for !impl AsMut<T> for !core::mem::DropGuardcore::mem::conjure_zstUnsafeCell::replaceUnsafeCell::as_ref_uncheckedUnsafeCell::as_mut_uncheckedstr::trim_prefixstr::trim_suffix[T]::trim_prefix[T]::trim_suffixPath::trim_prefixVec::from_fnos::windows::process::CommandExt::show_window