Rust versions / 1.62
Rust release · Jun 30, 2022
Rust 1.62: what's new, what was stabilized
Short answerRust 1.62 was released on Jun 30, 2022: 1 language stabilization ([Stabilize #[derive(Default)] on enums with a #[default] variant][94457]); 9 newly stable APIs (bool::then_some, f32::total_cmp, f64::total_cmp, Stdin::lines, ...); 5 compatibility notes that can affect existing code. Point release: 1.62.1 (Jul 19, 2022).
← Rust 1.61All versionsRust 1.63 →
Language features stabilized
- [Stabilize #[derive(Default)] on enums with a #[default] variant][94457]
9 APIs stabilized
bool::then_some, f32::total_cmp, f64::total_cmp, Stdin::lines, windows::CommandExt::raw_arg, impl<T: Default> Default for AssertUnwindSafe<T>, From<Rc<str>> for Rc<[u8]>, From<Arc<str>> for Arc<[u8]>, FusedIterator for EncodeWide
Can it break my build?
The release lists these compatibility notes. Most only affect rare code, but read them before you raise your toolchain in CI:
cargo testnow passes--targettorustdocif the specified target is- [rustdoc: doctests are now run on unexported
macro_rules!macros, matching other private items][96630] - [rustdoc: Remove .woff font files][96279]
- [Enforce Copy bounds for repeat elements while considering lifetimes][95819]
- [Windows: Fix potential unsoundness by aborting if
Filereads or writes cannot
Use it
rustup update stable # get the newest release
rustup install 1.62 # or exactly this one
rustup override set 1.62 # pin a project to itTo require at least this version from users of your crate, set rust-version = "1.62" under [package] in Cargo.toml. Cargo then refuses to build it on older compilers with a clear message, and with resolver 3 (the default on the 2024 edition, Rust 1.85+) it also prefers dependency versions that support it.
Full release notes
Language
- [Stabilize
#[derive(Default)]on enums with a#[default]variant][94457] - [Teach flow sensitive checks that visibly uninhabited call expressions never return][93313]
- [Fix constants not getting dropped if part of a diverging expression][94775]
- [Support unit struct/enum variant in destructuring assignment][95380]
- [Remove mutable_borrow_reservation_conflict lint and allow the code pattern][96268]
- [
constfunctions may now specifyextern "C"orextern "Rust"][95346]
Compiler
- [linker: Stop using whole-archive on dependencies of dylibs][96436]
- [Make
unaligned_referenceslint deny-by-default][95372] This lint is also a future compatibility lint, and is expected to eventually become a hard error. - [Only add codegen backend to dep info if -Zbinary-dep-depinfo is used][93969]
- [Reject
#[thread_local]attribute on non-static items][95006] - [Add tier 3
aarch64-pc-windows-gnullvmandx86_64-pc-windows-gnullvmtargets\*][94872] - [Implement a lint to warn about unused macro rules][96150]
- [Promote
x86_64-unknown-nonetarget to Tier 2\*][95705]
\* Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.
Libraries
- [Windows: Use a pipe relay for chaining pipes][95841]
- [Replace Linux Mutex and Condvar with futex based ones.][95035]
- [Replace RwLock by a futex based one on Linux][95801]
- [std: directly use pthread in UNIX parker implementation][96393]
Stabilized APIs
- [
bool::then_some] - [
f32::total_cmp] - [
f64::total_cmp] - [
Stdin::lines] - [
windows::CommandExt::raw_arg] - [
impl<T: Default> Default for AssertUnwindSafe<T>] - [
From<Rc<str>> for Rc<[u8]>][rc-u8-from-str] - [
From<Arc<str>> for Arc<[u8]>][arc-u8-from-str] - [
FusedIterator for EncodeWide] - [RDM intrinsics on aarch64][stdarch/1285]
Clippy
- [Create clippy lint against unexpectedly late drop for temporaries in match scrutinee expressions][94206]
Cargo
- Added the
cargo addcommand for adding dependencies toCargo.tomlfrom the command-line. docs - Package ID specs now support
name@versionsyntax in addition to the previousname:versionto align with the behavior incargo addand other tools.cargo installandcargo yankalso now support this syntax so the version does not need to passed as a separate flag. - The
gitandregistrydirectories in Cargo's home directory (usually~/.cargo) are now marked as cache directories so that they are not included in backups or content indexing (on Windows). - Added automatic
@argfile support, which will use "response files" if the command-line torustcexceeds the operating system's limit.
Compatibility Notes
cargo testnow passes--targettorustdocif the specified target is the same as the host target. #10594- [rustdoc: doctests are now run on unexported
macro_rules!macros, matching other private items][96630] - [rustdoc: Remove .woff font files][96279]
- [Enforce Copy bounds for repeat elements while considering lifetimes][95819]
- [Windows: Fix potential unsoundness by aborting if
Filereads or writes cannot complete synchronously][95469].
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.
1.62.1 (Jul 19, 2022)
Rust 1.62.1 addresses a few recent regressions in the compiler and standard library, and also mitigates a CPU vulnerability on Intel SGX.
- The compiler fixed unsound function coercions involving
impl Traitreturn types. - The compiler fixed an incremental compilation bug with
async fnlifetimes. - Windows added a fallback for overlapped I/O in synchronous reads and writes.
- The
x86_64-fortanix-unknown-sgxtarget added a mitigation for the MMIO stale data vulnerability, advisory INTEL-SA-00615.
Release notes from the Rust project's RELEASES.md (MIT or Apache-2.0); summaries above are ours.
Up next
Next releaseRust 1.63Released Aug 11, 2022.Read it next →Also worth your time
Did this answer your question?