Announcing Rust 1.99.0
Announcing Rust 1.99.0
Rust 1.99.0 发布公告
Oct. 1, 2026 · The Rust Release Team 2026 年 10 月 1 日 · Rust 发布团队
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 update stable
如果您通过 rustup 安装了旧版本的 Rust,可以通过以下命令获取 1.99.0:$ rustup update stable
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
extern “C” 可变参数
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 1.99.0 稳定了使用 “C” 和 “C-unwind” ABI 定义 C-ABI 可变参数函数的功能。以这种方式定义的可变参数函数使用可变参数列表(…)并接受任意数量的参数。
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 此前已经可以调用外部定义的可变参数函数(例如 libc::printf)。从 Rust 1.99 开始,这些函数现在可以直接用 Rust 编写:
/// SAFETY: must be called with (at least) 2 i32 arguments.
unsafe extern "C" fn sum(mut args: ...) -> i32 {
// SAFETY: guaranteed by the caller.
let a = unsafe { args.next_arg::<i32>() };
let b = unsafe { args.next_arg::<i32>() };
a + b
}
fn foo() -> i32 {
unsafe { sum(0i32, 2i32) }
}
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. For more details on c-variadic functions, see the Reference.
... 的类型是 VaList,它在各目标平台上与 C 语言的 va_list 类型 ABI 兼容。VaList 可以读取哪些类型由 VaArgSafe trait 保护。有关 C 可变参数函数的更多详细信息,请参阅参考手册。
This release also stabilizes support for defining naked variadic functions with non-”C” ABIs, which must be written via inline assembly. 此版本还稳定了对定义非 “C” ABI 的裸(naked)可变参数函数的支持,这些函数必须通过内联汇编编写。
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. This is done by stabilizing three functions: 此版本确定了获取指向 Sized 类型(已在稳定版中实现,非常简单)和非 Sized 类型原始指针的大小与对齐方式的安全要求。这通过稳定以下三个函数来实现:
Layout::for_value_rawmem::size_of_val_rawmem::align_of_val_raw
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. This guidance also applies to other leak functions in the standard library.
虽然 Rust 1.99 没有改变语言语义,但我们更新了 Box::leak 的文档,建议不要使用后续会释放该内存的模式。这是因为此类代码被发现与当前及未来潜在的编译器优化存在冲突,特别是在即将到来的自定义分配器稳定化之后问题尤为突出。建议优先使用 Box::into_non_null 或 Box::into_raw。此建议同样适用于标准库中的其他泄漏函数。
Stabilized APIs
已稳定的 API
IntoIterator for Box<[T; N]>IntoIterator for &Box<[T; N]>IntoIterator for &mut Box<[T; N]>VecDeque::retain_backcore::ffi::VaListBox::into_non_nullBox::from_non_nullVec::into_partsVec::from_partscore::mem::size_of_val_rawcore::mem::align_of_val_rawcore::alloc::Layout::for_value_rawString::from_utf8_lossy_ownedstring::FromUtf8Error::into_utf8_lossyFusedIterator for StepBy<I>std::fs::set_timesstd::fs::set_times_nofollow
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。没有你们,我们无法做到这一点。谢谢!