Update May 19, 2022 tracked by Updatify
Rust 1.61.0
Language
-
const fnsignatures can now include generic trait bounds -
const fnsignatures can now useimpl Traitin argument and return position -
Function pointers can now be created, cast, and passed around in a
const fn -
Recursive calls can now set the value of a function’s opaque
impl Traitreturn type
Compiler
-
Linking modifier syntax in
#[link]attributes and on the command line, as well as thewhole-archivemodifier specifically, are now supported -
The
chartype is now described as UTF-32 in debuginfo -
The
#[target_feature]attribute can now be used with aarch64 features -
X86
#[target_feature = "adx"]is now stable
Libraries
-
ManuallyDrop<T>is now documented to have the same layout asT -
#[ignore = "…"]messages are printed when running tests - Consistently show absent stdio handles on Windows as NULL handles
-
Make
std::io::stdio::lock()return'statichandles. Previously, the creation of locked handles to stdin/stdout/stderr would borrow the handles being locked, which prevented writinglet out = std::io::stdout().lock();becauseoutwould outlive the return value ofstdout(). Such code now works, eliminating a common pitfall that affected many Rust users. -
Vec::from_raw_partsis now less restrictive about its inputs -
std::thread::available_parallelismnow takes cgroup quotas into account. Sinceavailable_parallelismis often used to create a thread pool for parallel computation, which may be CPU-bound for performance,available_parallelismwill return a value consistent with the ability to use that many threads continuously, if possible. For instance, in a container with 8 virtual CPUs but quotas only allowing for 50% usage,available_parallelismwill return 4.
Stabilized APIs
-
Pin::static_mut -
Pin::static_ref -
Vec::retain_mut -
VecDeque::retain_mut -
WriteforCursor<[u8; N]> -
std::os::unix::net::SocketAddr::from_pathname -
std::process::ExitCodeandstd::process::Termination. The stabilization of these two APIs now makes it possible for programs to return errors frommainwith custom exit codes. -
std::thread::JoinHandle::is_finished
These APIs are now usable in const contexts:
-
<*const T>::offsetand<*mut T>::offset -
<*const T>::wrapping_offsetand<*mut T>::wrapping_offset -
<*const T>::addand<*mut T>::add -
<*const T>::suband<*mut T>::sub -
<*const T>::wrapping_addand<*mut T>::wrapping_add -
<*const T>::wrapping_suband<*mut T>::wrapping_sub -
<[T]>::as_mut_ptr -
<[T]>::as_ptr_range -
<[T]>::as_mut_ptr_range
Cargo
No feature changes, but see compatibility notes.
Compatibility Notes
-
Previously native static libraries were linked as
whole-archivein some cases, but now rustc tries not to usewhole-archiveunless explicitly requested. This change may result in linking errors in some cases. To fix such errors, native libraries linked from the command line, build scripts, or#[link]attributes need to-
(more common) either be reordered to respect dependencies between them (if
adepends onbthenashould go first andbsecond) -
(less common) or be updated to use the
+whole-archivemodifier.
-
(more common) either be reordered to respect dependencies between them (if
- Catching a second unwind from FFI code while cleaning up from a Rust panic now causes the process to abort
-
Proc macros no longer see
identmatchers wrapped in groups -
The number of
#inr#raw string literals is now required to be less than 256 - When checking that a dyn type satisfies a trait bound, supertrait bounds are now enforced
-
cargo vendornow only accepts one value for each--syncflag -
cfgpredicates inall()andany()are always evaluated to detect errors, instead of short-circuiting. The compatibility considerations here arise in nightly-only code that used the short-circuiting behavior ofallto write something likecfg(all(feature = "nightly", syntax-requiring-nightly)), which will now fail to compile. Instead, use eithercfg_attr(feature = "nightly", ...)or nested uses ofcfg. - bootstrap: static-libstdcpp is now enabled by default, and can now be disabled when llvm-tools is enabled
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.