返回综合榜
编程与语言Rust Blog

Rust 1.100.0 发布:历时十年 never 类型终稳定,Cargo 引入依赖冷却期

Rust 团队发布了 Rust 1.100.0,最大亮点是 never 类型(!)在历经十年、五次失败的稳定化尝试后终于稳定。此次变更还将 Infallible 改为 ! 的别名,使现有使用 Infallible 的 API 与 never 类型兼容。

在 2024 之前的 edition 中,never 类型回退从 () 改为 !,这在技术上是破坏性变更,但多数情况下不会造成影响。其他重要稳定化内容包括:可用于 Vec 和 Box 的自定义分配器核心 Allocator API、在所有退出路径上运行闭包的 core::mem::DropGuard,以及作为安全地创建零大小类型值专用方式的 std::mem::conjure_zst。

在 Cargo 方面,本次发布通过新的 [lints.cargo] 表增加未使用依赖警告,在构建目录中一致应用构建配置哈希以减少缓存冲突(这可能破坏依赖旧有变通方案的构建脚本),并稳定了 min-publish-age 依赖冷却期功能。

冷却期通过 .cargo/config.toml 中的 [registry] global-min-publish-age 配置,让 Cargo 跳过发布时间晚于设定窗口的版本。团队提醒这并非完整的供应链防御,cargo install 会忽略该设置,且缺少 pubtime 字段的 crate 永远不会被暂缓使用。

Rust 1.100.0 released: never type stabilized after 10 years, Cargo gains dependency cooldowns

The Rust team has released Rust 1.100.0, headlined by the stabilization of the never type (!) after 10 years and five failed attempts. The change also makes Infallible an alias for !, so existing APIs using Infallible become compatible with the never type.

The never type fallback changes from () to ! in editions before 2024, which is technically a breaking change but should mostly be unnoticeable. Other major stabilizations include the core Allocator API for custom allocators usable with Vec and Box, core::mem::DropGuard for running a closure on every exit path, and std::mem::conjure_zst as the dedicated unsafe way to create zero-sized values.

On the Cargo side, the release adds warnings for unused dependencies via the new [lints.cargo] table, applies build-configuration hashes consistently in the build directory to reduce cache collisions (which may break build scripts relying on old workarounds), and stabilizes min-publish-age dependency cooldowns.

Cooldowns, configured with [registry] global-min-publish-age in .cargo/config.toml, let Cargo skip versions published more recently than the configured window. The team notes this is not a complete supply-chain defense, that cargo install ignores the setting, and that crates lacking a pubtime field are never held back.

rustreleasenever typecargoallocatorsupply chainstabilization
综合16
质量91
猎物热度0
时效0
信息来源1 个来源,主来源:Rust Blog

猎鹰不保存原文正文。标题与摘要用于快速发现信息,事实细节请以来源原文为准。

查看来源