Version 1.58.1 (2022-01-20)
- Fix race condition in
std::fs::remove_dir_all
(CVE-2022-21658) - Handle captured arguments in the
useless_format
Clippy lint - Move
non_send_fields_in_send_ty
Clippy lint to nursery - Fix wrong error message displayed when some imports are missing
- Fix rustfmt not formatting generated files from stdin
Version 1.58.0 (2022-01-13)
Language
- Format strings can now capture arguments simply by writing
{ident}
in the string. 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 T
pointers can now be dereferenced in const contexts.- The rules for when a generic struct implements
Unsize
have been relaxed.
Compiler
- Add LLVM CFI support to the Rust compiler
- Stabilize -Z strip as -C strip. 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
- Emit LLVM optimization remarks when enabled with
-Cremark
- Update the minimum external LLVM to 12
- Add
x86_64-unknown-none
at Tier 3* - Build musl dist artifacts with debuginfo enabled. 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
- Error messages point at the source of trait bound obligations in more places
* 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
- Re-enable debug checks for
copy
andcopy_nonoverlapping
- Implement
RefUnwindSafe
forRc<T>
- Make RSplit<T, P>: Clone not require T: Clone
- Implement
Termination
forResult<Infallible, E>
. This allows writingfn main() -> Result<Infallible, ErrorType>
, for a program whose successful exits never involve returning frommain
(for instance, a program that callsexit
, or that usesexec
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
Rustdoc
Compatibility Notes
- Try all stable method candidates first before trying unstable ones. 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. - All proc-macro backward-compatibility lints are now deny-by-default.
- proc_macro: Append .0 to unsuffixed float if it would otherwise become int token
- Refactor weak symbols in std::sys::unix. 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
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.