rust-lang/rust 发布 1.98.0
Rust 1.98.0 发布:允许特定 &mut 生命周期缩短,新增 lint,提升多个 Tier 2 平台,稳定 LoongArch CRC 等。
中文处理结果
语言
- 允许在非协变位置进行 unsize 强制转换时缩短
&mut的生命周期。 例如,现在可以将Cell<&'long mut i32>强制转换为Cell<&'short mut dyn Send>。此前,在将&mut强制转换为&或将&强制转换为&时,已经允许这种缩短。 - 添加默认拒绝的
invalid_runtime_symbol_definitionslint 和默认警告的suspicious_runtime_symbol_definitionslint- 这些 lint 目前专门针对
core运行时符号,如memcmp、memset、strlen等,并计划在接下来的几个版本中扩展。
- 这些 lint 目前专门针对
- 添加默认警告的
c_void_returnslint,用于检查core::ffi::c_void作为返回类型
平台支持
- 添加
powerpc64-unknown-linux-gnuelfv2作为 Tier 3 - 添加
aarch64-unknown-linux-pauthtest作为 Tier 3 目标 - 将
thumbv7a-none-eabi提升至 Tier 2 - 将
thumbv7a-none-eabihf提升至 Tier 2 - 将
thumbv7r-none-eabi提升至 Tier 2 - 将
thumbv7r-none-eabihf提升至 Tier 2 - 将
thumbv8r-none-eabihf提升至 Tier 2
有关 Rust 分层平台支持的更多信息,请参阅 Rust 的平台支持页面。
库
- 将
Panic[Hook]Info中的Location<'_>生命周期更改为'static - 记录
RangeInclusive::from(legacy::RangeInclusive)中的 panic - 记录
ManuallyDrop的Box交互已修复 - 稳定 LoongArch CRC 内建函数
derive宏现在可在{core,std}::derive中使用。 这之前在 1.96 中意外稳定,但现在作为稳定 API 明确接受。- 请注意,
{core,std}::derive的 MSRV 将是 1.96,而不是 1.98。
- 请注意,
稳定 API
原始正文
rust-lang/rust released 1.98.0
Language
- Allow shortening lifetime of
&mutwhen unsize-coercing, even in an invariant position. For example, you can now coerce aCell<&'long mut i32>to aCell<&'short mut dyn Send>. Such shortenings were already previously allowed when coercing a&mutto a&, or coercing a&to a&. - Add deny-by-default
invalid_runtime_symbol_definitionslint and warn-by-defaultsuspicious_runtime_symbol_definitionslint- The lints currently specifically targets
coreruntime symbols likememcmp,memset,strlen, ... and is planned to be expanded in the next few releases.
- The lints currently specifically targets
- Add warn-by-default
c_void_returnslint to checkcore::ffi::c_voidas a return type
Platform Support
- Add
powerpc64-unknown-linux-gnuelfv2as Tier 3 - Add
aarch64-unknown-linux-pauthtestas Tier 3 target - Promote
thumbv7a-none-eabito Tier 2 - Promote
thumbv7a-none-eabihfto Tier 2 - Promote
thumbv7r-none-eabito Tier 2 - Promote
thumbv7r-none-eabihfto Tier 2 - Promote
thumbv8r-none-eabihfto Tier 2
Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
- Change
Location<'_>lifetime to'staticinPanic[Hook]Info - Document panic in
RangeInclusive::from(legacy::RangeInclusive) - Document that
ManuallyDrop'sBoxinteraction has been fixed - Stabilize LoongArch CRC Intrinsics
- The
derivemacro is available at{core,std}::derive. This was previously unintentionally stabilized in 1.96, but is now explicitly accepted as a stabilized API.- Please note that the MSRV for
{core,std}::derivewill be 1.96, and not 1.98.
- Please note that the MSRV for
Stabilized APIs
str::substr_range[T]::subslice_rangecore::fmt::NumBuffer<{integer}>::format_intoSend/Sync for std::process::CommandArgs{fN}::algebraic_add{fN}::algebraic_sub{fN}::algebraic_mul{fN}::algebraic_div{fN}::algebraic_remNonZero<{integer}>::from_str_radixString::from_utf16leString::from_utf16le_lossyString::from_utf16beString::from_utf16be_lossy[T]::strip_circumfixstr::strip_circumfixAtomic<T>::from_mutAtomic<T>::get_mut_sliceAtomic<T>::from_mut_slicestd::range::legacy
Compatibility Notes
- If fully elided, lifetime bounds of trait object types may now resolve differently or even get rejected in very specific niche scenarios
- Error in more cases of ambiguous imports
- Switch the destructors implementation for thread locals on Windows to use Fiber Local Storage (FLS)
- Convert some cases of the
ambiguous_glob_importslint into a hard error - Where-bounds of the form
Type = TypeandType == Typeare no longer syntactically allowed - Ensure Send/Sync is not implemented for std::env::Vars{,Os}
- Fix that in some attributes, arguments were not properly rejected
repr(transparent)is now more strict about which fields have "trivial" layout and hence can be ignored:repr(C)types, types with private fields, and#[non_exhaustive]types are no longer considered "trivial"- Correctly check whether types have equal size in
transmute()when somereprattributes are involved. - More characters are escaped when printing strings and chars
- Implement fast path for
derive(PartialOrd)when derivingOrdThis can break crates in practice where a type's PartialOrd and Ord impls were inconsistent with each other. - Add temporary scope to
assert_eqandassert_ne - Closed a hole in the pattern matching structural equality check, preventing cases where a match of a constant would be allowed, despite disagreeing with a manually written
PartialEqimplementation, when aderive(PartialEq)implementation for that type also exists. - On Emscripten the WASM exception handling ABI is now unconditionally used The
-Zemscripten-wasm-eh=falseflag to switch back to JS exceptions has been removed. - The UNSAFE_CODE lint is now consistently emitted for all unsafe attributes
- Solaris: remove
File::lockimplementation, it has the wrong semantics (return "unsupported" instead) - Windows-gnu targets now specify baseline tools versions
- rustfmt now discovers module files that are defined in
cfg_select!This may cause more code to be formatted which was previously ignored.