秋风携新锈,1.91.0 悄然绽放
秋风轻拂,代码之林再添新叶。Rust 团队欣然宣布,Rust 1.91.0 正式发布——这门赋能世人铸就可靠高效软件的编程语言,又迈出了坚实一步。
若您已通过 rustup 安装旧版,只需轻敲:
$ rustup update stable
即可拥抱新版。若尚未安装,可前往 Rust 官网 获取 rustup,并查阅 1.91.0 详细发布笔记。
欲助 Rust 团队测试未来版本,不妨切换至 beta 通道(rustup default beta)或 nightly 通道(rustup default nightly),并 报告 任何发现的 bug。
1.91.0 稳定版亮点
aarch64-pc-windows-msvc 荣升 Tier 1 平台
Rust 编译器支持 众多目标平台,但支持力度因阶层而异:
- Tier 3:编译器技术支持,但不检查构建或测试,无预编译二进制文件。
 - Tier 2:保证构建并提供预编译二进制,但不运行测试套件,二进制可能存在缺陷。
 - Tier 1:最高保障,每合并变更均运行全套测试,并提供预编译二进制。
 
Rust 1.91.0 将 aarch64-pc-windows-msvc 目标提升至 Tier 1,为 64 位 ARM Windows 用户带来最高级别保证。
新增对局部变量悬垂原始指针的默认警告 lint
Rust 的借用检查器可防止悬垂引用返回,但对原始指针无能为力。本版引入默认警告 lint,针对从函数返回指向局部变量的原始指针。例如:
fn f() -> *const u8 {
    let x = 0;
    &x
}
将触发警告:
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
此代码本身并非 unsafe,仅在函数返回后解引用原始指针才属 unsafe。未来版本将进一步增强对原始指针及 unsafe 代码的安全交互支持。
稳定化 API
Path::file_prefixAtomicPtr::fetch_ptr_addAtomicPtr::fetch_ptr_subAtomicPtr::fetch_byte_addAtomicPtr::fetch_byte_subAtomicPtr::fetch_orAtomicPtr::fetch_andAtomicPtr::fetch_xor{integer}::strict_add等严格整数运算系列(涵盖 add、sub、mul、div、div_euclid、rem、rem_euclid、neg、shl、shr、pow)i{N}::strict_add_unsigned等有符号/无符号混合严格运算PanicHookInfo::payload_as_strcore::iter::chainu{N}::checked_signed_diffcore::array::repeatPathBuf::add_extension与PathBuf::with_added_extensionDuration::from_mins与Duration::from_hoursPath/PathBuf与str/String的PartialEq实现系列Ipv4Addr::from_octets、Ipv6Addr::from_octets、Ipv6Addr::from_segmentsPin<Box<T>>、Pin<Rc<T>>、Pin<Arc<T>>的Default实现Cell::as_array_of_cells- 无符号整数的进位/借位运算:
u{N}::carrying_add、u{N}::borrowing_sub、u{N}::carrying_mul、u{N}::carrying_mul_add BTreeMap::extract_if与BTreeSet::extract_ifimpl Debug for windows::ffi::EncodeWide<'_>str::ceil_char_boundary与str::floor_char_boundarySaturating<u{N}>的Sum与Product实现(含&Self变体)
const 上下文中稳定化的原有 API
<[T; N]>::each_ref<[T; N]>::each_mutOsString::newPathBuf::newTypeId::ofptr::with_exposed_provenance与ptr::with_exposed_provenance_mut
平台支持更新
- 将 
aarch64-pc-windows-msvc提升至 Tier 1 - 将 
aarch64-pc-windows-gnullvm与x86_64-pc-windows-gnullvm提升至 Tier 2 并支持 host tools
(注:llvm-tools 与 MSI 安装器暂缺,后续版本补齐) 
详见 Rust 平台支持页面。
其他变更
致谢 1.91.0 贡献者
无数双手共同铸就 Rust 1.91.0,离不开每一位贡献者。感谢你们!
版权声明:自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)