Rust 1.91.0 稳定版发布

软件资讯 软件资讯 发布于 6小时前 0 浏览 0 回复

Rust 1.91.0 稳定版已正式发布,主要带来以下变化:

aarch64-pc-windows-msvc现在是 Tier 1 平台

Rust 编译器支持多种目标平台,但 Rust 团队无法为所有平台提供同等程度的支持。为了清晰地标明每个目标平台的支持程度,使用了分级系统:

  • Tier 3 targets 在技术上得到编译器支持,但官方不检查其代码是否能够构建或通过测试,也不在发布版本中提供任何预构建的二进制文件。
  • Tier 2 targets 保证能够构建,并且提供预构建的二进制文件,但官方不会在这些平台上执行测试套件:生成的二进制文件可能无法工作或存在错误。
  • Tier 1 targets 提供最高级别的支持保障,对于编译器中合并的每一项更改,都会在这些平台上运行完整的测试套件。此外,还提供预编译的二进制文件。

Rust 1.91.0 将aarch64-pc-windows-msvctarget 提升至 Tier 1 支持级别,为运行 Windows 的 64 位 ARM 系统用户提供最高级别的保障。

添加针对局部变量中悬空原始指针的 lint 规则

虽然 Rust 的借用检查可以防止返回悬空引用,但它不会跟踪原始指针。在此版本中,添加了一个默认警告的 lint,用于检查函数返回的指向局部变量的原始指针。例如,类似这样的代码:

fn f() -> *const u8 {
    let x = 0;
    &x
}

现在将生成一个 lint:

warning: a dangling pointer will be produced because the local variable `x` will be dropped
 --> src/lib.rs:3:5
  |
1 | fn f() -> *const u8 {
  |           --------- return type of the function is `*const u8`
2 |     let x = 0;
  |         - `x` is part the function and will be dropped at the end of the function
3 |     &x
  |     ^^
  |
  = note: pointers do not have a lifetime; after returning, the `u8` will be deallocated
    at the end of the function because nothing is referencing it as far as the type system is
    concerned
  = note: `#[warn(dangling_pointers_from_locals)]` on by default

值得注意的是,上面的代码本身并不危险,因为它没有执行任何危险操作。只有在函数返回后解引用原始指针才是不安全的。“我们期望 Rust 的未来版本能够添加更多功能,帮助开发者安全地处理原始指针,以及更广泛意义上的不安全代码。”

平台支持

  • 将 aarch64-pc-windows-msvc 提升至 Tier 1 支持
  • 将 aarch64-pc-windows-gnullvm 和 x86_64-pc-windows-gnullvm 提升至 Tier 2 支持,并提供 host tools。注意:llvm-tools 和 MSI 安装程序目前缺失,将在未来版本中添加。

更多详情可查看:https://blog.rust-lang.org/2025/10/30/Rust-1.91.0/



为您推荐相关文章:

  • Rust 1.68.0 现已发布
  • Rust 1.68.1 发布
  • Rust 1.77.0 发布
  • Rust 1.80.0 发布
  • Rust 1.72.0 发布,未来支持版本最低为 Windows 10
  • 同类文章推荐:

  • BootstrapBlazor
  • JetBrains 调研:2025 年最受欢迎的 Python 框架和库
  • FastDFS 6.15 发布,支持多线程同步
  • Gradle 9.2.0 发布
  • Fedora Linux 43 正式发布
  • Photoshop 正式接入 ChatGPT