跪拜 Guibai
← All articles
Rust

Rust 1.100.0 finally stabilizes the never type, adds custom allocators, and ships Cargo dependency cooldowns

By RockByte ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The never type closes a decade-long gap in error-handling ergonomics, and the allocator API starts a path to custom memory management for production Rust. Cargo's publish-age cooldown gives every project a cheap, configurable guard against the first hours of a supply-chain attack, even though it is not a complete defense.

Summary

Rust 1.100.0, released November 12, finally stabilizes the never type, a feature that failed five times over ten years before landing. The type, written `!`, can now appear in any type position, and `Infallible` becomes an alias for it. That alias carries a breaking change: editions before 2024 now fall back to `!` instead of `()` when the target of a coercion cannot be inferred, so code that relied on `()` to infer a `Result` type may fail to compile, though future-compatibility warnings went out in advance.

On the library side, the core of `allocator_api` is stable, so custom allocators can back `Vec` and `Box` through the new `Allocator` trait, with more collections and pointer types to come. `core::mem::DropGuard` runs a closure on drop and supports `dismiss` to skip it, making transactional rollback on parse failures direct. `std::mem::conjure_zst` formalizes unsafe construction of zero-sized types when safety invariants are satisfied.

Cargo picks up several hygiene and security features. An unused-dependency warning reports dependencies no target uses, but only after all targets are built. A new `global-min-publish-age` setting makes the resolver skip versions published within a configurable cooldown, blocking packages likely to be malicious for the first hours or days; `cargo install` ignores the setting. The build directory layout now applies configuration hashes to directories instead of filenames, cutting cache conflicts across git worktrees and build configurations.

Takeaways
— Rust 1.100.0 stabilizes the never type (`!`) after ten years of attempts; it can be used in any type position.
— `Infallible` becomes an alias for `!`; editions before 2024 switch coercion fallback from `()` to `!`, with warnings issued in advance.
— The core `allocator_api` is stable; `Vec` and `Box` accept custom allocators through the `Allocator` trait.
— `core::mem::DropGuard` runs a closure on drop and `dismiss` disarms it, enabling rollback on failure in a transactional parse API.
— `std::mem::conjure_zst` is the sanctioned unsafe way to construct zero-sized types when safety invariants hold.
— Cargo warns about unused dependencies only after all targets that could use a dependency have been built; `dev-dependencies` are not checked.
— Cargo's `global-min-publish-age` setting blocks versions newer than the configured window; `cargo install` ignores it.
— Cargo applies build-configuration hashes to directories instead of filenames, reducing cache conflicts across worktrees.
Conclusions

The ten-year road to never type stabilization shows how one breaking change, the `Infallible` alias, can hold back a feature long after its design is settled.

DropGuard turns a common implement-Drop-for-cleanup pattern into a one-liner, but the associated-function `dismiss` design is what keeps it usable with `DerefMut`.

The unused-dependency warning is best-effort by construction, since Cargo cannot know whether every target has been built; the lint's usefulness depends on whole-workspace builds.

Min-publish-age shifts part of supply-chain defense onto the resolver, but its own documented limitations make clear it is a first line, not a complete mitigation.

Concepts & terms
never type
A type with no values, written `!`, used for expressions that never return normally. It coerces implicitly to any other type and now appears in any type position.
Infallible
A standard library type that indicates an operation cannot fail; in Rust 1.100.0 it becomes an alias for the never type.
dependency cooldown
A Cargo setting that prevents the resolver from selecting versions published within a configurable window, reducing exposure to freshly released malicious packages.
DropGuard
A helper type in `core::mem` that runs a closure when dropped, allowing scoped cleanup or rollback without defining a custom `Drop` impl.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗