Rust 1.58.0
Released on January 13, 2022
What's Changed
- [Format strings can now capture arguments simply by writing
{ident}in the string.][90473] This works in all macros accepting format strings. Support for this inpanic!(panic!("{ident}")) requires the 2021 edition; panic invocations in previous editions that appear to be trying to use this will result in a warning lint about not having the intended effect. - [
*const Tpointers can now be dereferenced in const contexts.][89551] - [The rules for when a generic struct implements
Unsizehave been relaxed.][90417]
- [Add LLVM CFI support to the Rust compiler][89652]
- [Stabilize -Z strip as -C strip][90058]. Note that while release builds already don't add debug symbols for the code you compile, the compiled standard library that ships with Rust includes debug symbols, so you may want to use the
stripoption to remove these symbols to produce smaller release binaries. Note that this release only includes support in rustc, not directly in cargo. - [Add support for LLVM coverage mapping format versions 5 and 6][91207]
- [Emit LLVM optimization remarks when enabled with
-Cremark][90833] - [Update the minimum external LLVM to 12][90175]
- [Add
x86_64-unknown-noneat Tier 3*][89062] - [Build musl dist artifacts with debuginfo enabled][90733]. When building release binaries using musl, you may want to use the newly stabilized strip option to remove these debug symbols, reducing the size of your binaries.
- [Don't abort compilation after giving a lint error][87337]
- [Error messages point at the source of trait bound obligations in more places][89580]
- [All remaining functions in the standard library have
#[must_use]annotations where appropriate][89692], producing a warning when ignoring their return value. This helps catch mistakes such as expecting a function to mutate a value in place rather than return a new value. - [Paths are automatically canonicalized on Windows for operations that support it][89174]
- [Re-enable debug checks for
copyandcopy_nonoverlapping][90041] - [Implement
RefUnwindSafeforRc][87467] - [Make RSplit
: Clone not require T: Clone][90117] - [Implement
TerminationforResult][88601]. This allows writingfn main() -> Result, for a program whose successful exits never involve returning frommain(for instance, a program that callsexit, or that usesexecto run another program). - [
Metadata::is_symlink] - [
Path::is_symlink] - [
{integer}::saturating_div] - [
Option::unwrap_unchecked] - [
Result::unwrap_unchecked] - [
Result::unwrap_err_unchecked] - [
File::options] - [
Duration::new] - [
Duration::checked_add] - [
Duration::saturating_add] - [
Duration::checked_sub] - [
Duration::saturating_sub] - [
Duration::checked_mul] - [
Duration::saturating_mul] - [
Duration::checked_div]
- [Add --message-format for install command][cargo/10107]
- [Warn when alias shadows external subcommand][cargo/10082]
- [Try all stable method candidates first before trying unstable ones][90329]. This change ensures that adding new nightly-only methods to the Rust standard library will not break code invoking methods of the same name from traits outside the standard library.
- Windows: [
std::process::Commandwill no longer search the current directory for executables.][87704] - [All proc-macro backward-compatibility lints are now deny-by-default.][88041]
- [proc_macro: Append .0 to unsuffixed float if it would otherwise become int token][90297]
- [Refactor weak symbols in std::sys::unix][90846]. This optimizes accesses to glibc functions, by avoiding the use of dlopen. This does not increase the minimum expected version of glibc. However, software distributions that use symbol versions to detect library dependencies, and which take weak symbols into account in that analysis, may detect rust binaries as requiring newer versions of glibc.
- [rustdoc now rejects some unexpected semicolons in doctests][91026]
- [Show all Deref implementations recursively in rustdoc][90183]
- [Use computed visibility in rustdoc][88447]
- [Implement coherence checks for negative trait impls][90104]
- [Add rustc lint, warning when iterating over hashmaps][89558]
- [Optimize live point computation][90491]
- [Enable verification for 1/32nd of queries loaded from disk][90361]
- [Implement version of normalize_erasing_regions that allows for normalization failure][91255]
Full Changelog
Language
--------
- [Format strings can now capture arguments simply by writing {ident} in the string.][90473] This works in all macros accepting format strings. Support for this in panic! (panic!("{ident}")) requires the 2021 edition; panic invocations in previous editions that appear to be trying to use this will result in a warning lint about not having the intended effect.
- [*const T pointers can now be dereferenced in const contexts.][89551]
- [The rules for when a generic struct implements Unsize have been relaxed.][90417]
Compiler
--------
- [Add LLVM CFI support to the Rust compiler][89652]
- [Stabilize -Z strip as -C strip][90058]. Note that while release builds already don't add debug symbols for the code you compile, the compiled standard library that ships with Rust includes debug symbols, so you may want to use the strip option to remove these symbols to produce smaller release binaries. Note that this release only includes support in rustc, not directly in cargo.
- [Add support for LLVM coverage mapping format versions 5 and 6][91207]
- [Emit LLVM optimization remarks when enabled with -Cremark][90833]
- [Update the minimum external LLVM to 12][90175]
- [Add x86_64-unknown-none at Tier 3*][89062]
- [Build musl dist artifacts with debuginfo enabled][90733]. When building release binaries using musl, you may want to use the newly stabilized strip option to remove these debug symbols, reducing the size of your binaries.
- [Don't abort compilation after giving a lint error][87337]
- [Error messages point at the source of trait bound obligations in more places][89580]
\* Refer to Rust's [platform support page][platform-support-doc] for more
information on Rust's tiered platform support.
Libraries
---------
- [All remaining functions in the standard library have #[must_use] annotations where appropriate][89692], producing a warning when ignoring their return value. This helps catch mistakes such as expecting a function to mutate a value in place rather than return a new value.
- [Paths are automatically canonicalized on Windows for operations that support it][89174]
- [Re-enable debug checks for copy and copy_nonoverlapping][90041]
- [Implement RefUnwindSafe for Rc][87467]
- [Make RSplit
- [Implement Termination for Result][88601]. This allows writing fn main() -> Result, for a program whose successful exits never involve returning from main (for instance, a program that calls exit, or that uses exec to run another program).
Stabilized APIs
---------------
- [Metadata::is_symlink]
- [Path::is_symlink]
- [{integer}::saturating_div]
- [Option::unwrap_unchecked]
- [Result::unwrap_unchecked]
- [Result::unwrap_err_unchecked]
- [File::options]
These APIs are now usable in const contexts:
- [Duration::new]
- [Duration::checked_add]
- [Duration::saturating_add]
- [Duration::checked_sub]
- [Duration::saturating_sub]
- [Duration::checked_mul]
- [Duration::saturating_mul]
- [Duration::checked_div]
Cargo
-----
- [Add --message-format for install command][cargo/10107]
- [Warn when alias shadows external subcommand][cargo/10082]
Rustdoc
-------
- [Show all Deref implementations recursively in rustdoc][90183]
- [Use computed visibility in rustdoc][88447]
Compatibility Notes
-------------------
- [Try all stable method candidates first before trying unstable ones][90329]. This change ensures that adding new nightly-only methods to the Rust standard library will not break code invoking methods of the same name from traits outside the standard library.
- Windows: [std::process::Command will no longer search the current directory for executables.][87704]
- [All proc-macro backward-compatibility lints are now deny-by-default.][88041]
- [proc_macro: Append .0 to unsuffixed float if it would otherwise become int token][90297]
- [Refactor weak symbols in std::sys::unix][90846]. This optimizes accesses to glibc functions, by avoiding the use of dlopen. This does not increase the minimum expected version of glibc. However, software distributions that use symbol versions to detect library dependencies, and which take weak symbols into account in that analysis, may detect rust binaries as requiring newer versions of glibc.
- [rustdoc now rejects some unexpected semicolons in doctests][91026]
Internal Changes
----------------
These changes provide no direct user facing benefits, but represent significant
improvements to the internals and overall performance of rustc
and related tools.
- [Implement coherence checks for negative trait impls][90104]
- [Add rustc lint, warning when iterating over hashmaps][89558]
- [Optimize live point computation][90491]
- [Enable verification for 1/32nd of queries loaded from disk][90361]
- [Implement version of normalize_erasing_regions that allows for normalization failure][91255]
[87337]: https://github.com/rust-lang/rust/pull/87337/
[87467]: https://github.com/rust-lang/rust/pull/87467/
[87704]: https://github.com/rust-lang/rust/pull/87704/
[88041]: https://github.com/rust-lang/rust/pull/88041/
[88447]: https://github.com/rust-lang/rust/pull/88447/
[88601]: https://github.com/rust-lang/rust/pull/88601/
[89062]: https://github.com/rust-lang/rust/pull/89062/
[89174]: https://github.com/rust-lang/rust/pull/89174/
[89551]: https://github.com/rust-lang/rust/pull/89551/
[89558]: https://github.com/rust-lang/rust/pull/89558/
[89580]: https://github.com/rust-lang/rust/pull/89580/
[89652]: https://github.com/rust-lang/rust/pull/89652/
[90041]: https://github.com/rust-lang/rust/pull/90041/
[90058]: https://github.com/rust-lang/rust/pull/90058/
[90104]: https://github.com/rust-lang/rust/pull/90104/
[90117]: https://github.com/rust-lang/rust/pull/90117/
[90175]: https://github.com/rust-lang/rust/pull/90175/
[90183]: https://github.com/rust-lang/rust/pull/90183/
[90297]: https://github.com/rust-lang/rust/pull/90297/
[90329]: https://github.com/rust-lang/rust/pull/90329/
[90361]: https://github.com/rust-lang/rust/pull/90361/
[90417]: https://github.com/rust-lang/rust/pull/90417/
[90473]: https://github.com/rust-lang/rust/pull/90473/
[90491]: https://github.com/rust-lang/rust/pull/90491/
[90733]: https://github.com/rust-lang/rust/pull/90733/
[90833]: https://github.com/rust-lang/rust/pull/90833/
[90846]: https://github.com/rust-lang/rust/pull/90846/
[91026]: https://github.com/rust-lang/rust/pull/91026/
[91207]: https://github.com/rust-lang/rust/pull/91207/
[91255]: https://github.com/rust-lang/rust/pull/91255/
[cargo/10082]: https://github.com/rust-lang/cargo/pull/10082/
[cargo/10107]: https://github.com/rust-lang/cargo/pull/10107/
[Metadata::is_symlink]: https://doc.rust-lang.org/stable/std/fs/struct.Metadata.html#method.is_symlink
[Path::is_symlink]: https://doc.rust-lang.org/stable/std/path/struct.Path.html#method.is_symlink
[{integer}::saturating_div]: https://doc.rust-lang.org/stable/std/primitive.i8.html#method.saturating_div
[Option::unwrap_unchecked]: https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.unwrap_unchecked
[Result::unwrap_unchecked]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.unwrap_unchecked
[Result::unwrap_err_unchecked]: https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.unwrap_err_unchecked
[File::options]: https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.options
[Duration::new]: https://doc.rust-lang.org/stable/std/time/struct.Duration.html#method.new