rust-lang/rust 发布 1.97.0
Rust 1.97.0 发布:语言特性更新、平台支持调整、稳定 API 与 Cargo 变更。
中文处理结果
语言
- 对于 must use lint,将
Result<T, Uninhabited>和ControlFlow<Uninhabited, T>视为与T等价(PR #148214) - 为二进制 crate 中未使用的 pub 项添加默认允许的
dead_code_pub_in_binarylint(PR #149509) - 稳定
div32、lam-bh、lamcas、ld-seq-sa和scq目标特性(PR #154510) - 稳定
cfg(target_has_atomic_primitive_alignment)(PR #155006) - 在更多情况下允许在导入中使用尾部
self(PR #155137)
平台支持
- nvptx64-nvidia-cuda:放弃对旧架构和旧 ISA 的支持(PR #152443)
有关 Rust 分级平台支持的更多信息,请参阅 平台支持页面。
稳定 API
RepeatN的Default实现ffi::FromBytesUntilNulError的Copy实现- UEFI 上
std::fs::File的Send实现 <{integer}>::isolate_highest_one<{integer}>::isolate_lowest_one<{integer}>::highest_one<{integer}>::lowest_one<{integer}>::bit_widthNonZero<{integer}>::isolate_highest_oneNonZero<{integer}>::isolate_lowest_oneNonZero<{integer}>::highest_oneNonZero<{integer}>::lowest_oneNonZero<{integer}>::bit_width
这些先前稳定的 API 现在在 const 上下文中稳定:
Cargo
原始正文
rust-lang/rust released 1.97.0
Language
- Consider
Result<T, Uninhabited>andControlFlow<Uninhabited, T>to be equivalent toTfor must use lint - Add allow-by-default
dead_code_pub_in_binarylint for unused pub items in binary crates - Stabilize the
div32,lam-bh,lamcas,ld-seq-saandscqtarget features - Stabilize
cfg(target_has_atomic_primitive_alignment) - Allow trailing
selfin imports in more cases
Platform Support
Refer to Rust's platform support page for more information on Rust's tiered platform support.
Stabilized APIs
Default for RepeatNCopy for ffi::FromBytesUntilNulErrorSend for std::fs::Fileon UEFI<{integer}>::isolate_highest_one<{integer}>::isolate_lowest_one<{integer}>::highest_one<{integer}>::lowest_one<{integer}>::bit_widthNonZero<{integer}>::isolate_highest_oneNonZero<{integer}>::isolate_lowest_oneNonZero<{integer}>::highest_oneNonZero<{integer}>::lowest_oneNonZero<{integer}>::bit_width
These previously stable APIs are now stable in const contexts:
Cargo
- Stabilize
build.warningsconfig. This controls how lint warnings from local packages are treated. Useful for enforcing a warning-free build in CI, replacing-Dwarnings. docs - Stabilize
resolver.lockfile-pathconfig. This allows specifying the path to the lockfile to use when resolving dependencies. Useful when working with read-only source directories. docs - cargo-clean: Error when
--target-dirdoesn't look like a Cargo target directory. This prevents accidental deletion of non-target directories. - Add
-mshorthand for--manifest-path - Remove
curldependency fromcrates-iocrate
Rustdoc
Compatibility Notes
- Emit a future-compatibility warning when relying on
f32: From<{float}>to constrain{float} - Rust will use the v0 symbol mangling scheme by default. This may cause some tools (such as debuggers or profilers, especially with old versions) to fail to demangle symbols emitted by Rust. It may also cause the formatting of text in backtraces to change.
- Prevent deref coercions in
pin!, in order to prevent unsoundness. The most likely case where this might impact users is: writingpin!(x)wherexhas type&mut Twill now always correctly produce a value of typePin<&mut &mut T>, instead of sometimes allowing a coercion that produces a value of typePin<&mut T>. This coercion was previously incorrectly allowed since Rust 1.88.0. - Deprecate
std::charconstants and functions - Warn on linker output by default
- Remove hidden
f64methods which have been deprecated since 1.0 - report the
varargs_without_patternlint in deps - Forbid passing generic arguments to module path segments even if the module reexports a generic enum variant
- Error on invalid macho
link_sectionspecifier - The encoding of certain
enums have changed. This is not a breaking change, as it only applies toenums without layout guarantees, but is noted here as we've seen people impacted from having made assumptions about the layout algorithm. - Error on
#[export_name = "..."]where the name is empty - Syntactically reject tuple index shorthands in struct patterns
- validate
#[link_name = "..."]&#[link(name = "...")]parameters - On Windows, after calling
shutdownon a socket to shut down the write side, attempting to write to the socket will now produce aBrokenPipeerror rather thanOther. MapWSAESHUTDOWNtoio::ErrorKind::BrokenPipe