[翻译]Rust 1.99.0 发布公告
- 原文地址:Announcing Rust 1.99.0
- 原作者:The Rust Release Team
- 原文发表于:2026-10-01
- 原文许可:MIT / Apache-2.0
The Rust team is happy to announce a new version of Rust, 1.99.0. Rust is a programming language empowering everyone to build reliable and efficient software.
Rust 团队很高兴地宣布,Rust 1.99.0 正式发布。Rust 是一门让每个人都能构建可靠、高效软件的编程语言。
If you have a previous version of Rust installed via rustup, you can get 1.99.0 with:
如果你此前通过 rustup 安装过 Rust,可以运行以下命令升级到 1.99.0:
|
If you don’t have it already, you can get rustup from the appropriate page on our website, and check out the detailed release notes for 1.99.0.
如果你还没有安装,可以在官网的安装页面获取 rustup,并查看 1.99.0 的详细发行说明。
If you’d like to help us out by testing future releases, you might consider updating locally to use the beta channel (rustup default beta) or the nightly channel (rustup default nightly). Please report any bugs you might come across!
如果你愿意帮助我们测试后续版本,可以考虑在本地切换到 beta 通道(rustup default beta)或 nightly 通道(rustup default nightly)。遇到任何 bug,都请向我们报告!
What’s in 1.99.0 stable 1.99.0 稳定版有哪些更新
extern "C" variadics 可变参数函数
Rust 1.99.0 stabilizes defining C-ABI variadic functions with “C” and “C-unwind” ABIs. Variadic functions defined this way use a variable argument list (...) and accept an arbitrary number of arguments. Rust could already call externally-defined variadic functions (e.g., libc::printf). With Rust 1.99, these functions can now be written in Rust itself:
Rust 1.99.0 将使用 "C" 和 "C-unwind" ABI 定义 C ABI 可变参数函数的功能正式稳定化。这类函数使用可变参数列表(...),可以接收任意数量的参数。Rust 此前已经能够调用在外部定义的可变参数函数,例如 libc::printf。从 Rust 1.99 开始,这些函数也可以直接用 Rust 编写了:
|
The type of ... is VaList, which is ABI-compatible with the C va_list type across targets. What types can be read from a VaList is guarded by the VaArgSafe trait.
... 的类型是 VaList,它在各个目标平台上都与 C 的 va_list 类型保持 ABI 兼容。哪些类型可以从 VaList 中读取,由 VaArgSafe trait 约束。
For more details on c-variadic functions, see the Reference. This release also stabilizes support for defining naked variadic functions with non-“C” ABIs, which must be written via inline assembly.
有关 C 可变参数函数的更多细节,请参阅 Rust 参考手册。本次发布还稳定了使用非 "C" ABI 定义裸可变参数函数(naked variadic functions)的功能,这类函数必须通过内联汇编编写。
Layout information from raw pointers 从裸指针获取布局信息
This release settles the safety requirements for retrieving the size and alignment on raw pointers to both Sized (trivially safe, already possible on stable) and non-Sized types.
本次发布明确了通过裸指针获取 Sized 类型和非 Sized 类型的大小及对齐要求时,需要满足的安全条件。对于 Sized 类型,这一操作本身就是安全的,而且稳定版早已支持。
This is done by stabilizing three functions:
为此,本次发布稳定了以下三个函数:
Recommend against round-trip unleaking after Box::leak 不建议在调用 Box::leak 后再释放内存
While there are no changes to the language semantics in Rust 1.99, we have updated the documentation on Box::leak to recommend against patterns that later deallocate that memory. This was done because such code was found to have problematic interactions with current and future potential compiler optimizations, and is especially problematic with the upcoming stabilization of custom allocators. Instead, Box::into_non_null or Box::into_raw should be preferred.
Rust 1.99 并未改变相关的语言语义,但我们更新了 Box::leak 的文档,建议避免先泄漏内存、之后又将其释放的用法。原因在于,我们发现这类代码与当前的编译器优化,以及未来可能引入的优化之间存在问题;随着自定义分配器支持即将稳定,这个问题尤其突出。应优先使用 Box::into_non_null 或 Box::into_raw。
This guidance also applies to other leak functions in the standard library.
这一建议也适用于标准库中的其他 leak 函数。
Stabilized APIs 已稳定的 API
-
为
Box<[T; N]>实现IntoIterator。 -
为
&Box<[T; N]>实现IntoIterator。 IntoIteratorfor&mut Box<[T; N]>为
&mut Box<[T; N]>实现IntoIterator。-
为
StepBy<I>实现FusedIterator。
Other changes 其他变更
Check out everything that changed in Rust, Cargo, and Clippy.
完整的变更列表,请查看 Rust、Cargo 和 Clippy 的发行说明。
Contributors to 1.99.0 1.99.0 的贡献者
Many people came together to create Rust 1.99.0. We couldn’t have done it without all of you. Thanks!
许多人共同参与了 Rust 1.99.0 的开发。没有大家的贡献,我们就无法完成这个版本。谢谢你们!
最后更新: