Version 1.61.0 (2022-05-19)
Language
const fn
signatures can now include generic trait boundsconst fn
signatures can now useimpl Trait
in 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 Trait
return type
Compiler
- Linking modifier syntax in
#[link]
attributes and on the command line, as well as thewhole-archive
modifier specifically, are now supported - The
char
type 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'static
handles. Previously, the creation of locked handles to stdin/stdout/stderr would borrow the handles being locked, which prevented writinglet out = std::io::stdout().lock();
becauseout
would outlive the return value ofstdout()
. Such code now works, eliminating a common pitfall that affected many Rust users. Vec::from_raw_parts
is now less restrictive about its inputsstd::thread::available_parallelism
now takes cgroup quotas into account. Sinceavailable_parallelism
is often used to create a thread pool for parallel computation, which may be CPU-bound for performance,available_parallelism
will 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_parallelism
will return 4.
Stabilized APIs
Pin::static_mut
Pin::static_ref
Vec::retain_mut
VecDeque::retain_mut
Write
forCursor<[u8; N]>
std::os::unix::net::SocketAddr::from_pathname
std::process::ExitCode
andstd::process::Termination
. The stabilization of these two APIs now makes it possible for programs to return errors frommain
with custom exit codes.std::thread::JoinHandle::is_finished
These APIs are now usable in const contexts:
<*const T>::offset
and<*mut T>::offset
<*const T>::wrapping_offset
and<*mut T>::wrapping_offset
<*const T>::add
and<*mut T>::add
<*const T>::sub
and<*mut T>::sub
<*const T>::wrapping_add
and<*mut T>::wrapping_add
<*const T>::wrapping_sub
and<*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-archive
in some cases, but now rustc tries not to usewhole-archive
unless 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
a
depends onb
thena
should go first andb
second) - (less common) or be updated to use the
+whole-archive
modifier.
- (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
ident
matchers 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 vendor
now only accepts one value for each--sync
flagcfg
predicates 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 ofall
to 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.