Rust versions / 1.42
Rust release · Mar 12, 2020
Rust 1.42: what's new, what was stabilized
Short answerRust 1.42 was released on Mar 12, 2020: 8 newly stable APIs (CondVar::wait_while, CondVar::wait_timeout_while, DebugMap::key, DebugMap::value, ...); 1 compatibility note that can affect existing code.
← Rust 1.41All versionsRust 1.43 →
8 APIs stabilized
CondVar::wait_while, CondVar::wait_timeout_while, DebugMap::key, DebugMap::value, ManuallyDrop::take, matches!, ptr::slice_from_raw_parts_mut, ptr::slice_from_raw_parts
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:
- [
Error::descriptionhas been deprecated, and its use will now produce a
Use it
rustup update stable # get the newest release
rustup install 1.42 # or exactly this one
rustup override set 1.42 # pin a project to itTo require at least this version from users of your crate, set rust-version = "1.42" 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
- [You can now use the slice pattern syntax with subslices.][67712] e.g. ``
rust fn foo(words: &[&str]) { match words { ["Hello", "World", "!", ..] => println!("Hello World!"), ["Foo", "Bar", ..] => println!("Baz"), rest => println!("{:?}", rest), } }`` - [You can now use
#[repr(transparent)]on univariantenums.][68122] Meaning that you can create an enum that has the exact layout and ABI of the type it contains. - [You can now use outer attribute procedural macros on inline modules.][64273]
- [There are some *syntax-only* changes:][67131]
defaultis syntactically allowed before items intraitdefinitions.- Items in
impls (i.e.consts,types, andfns) may syntactically leave out their bodies in favor of;. - Bounds on associated types in
impls are now syntactically allowed (e.g.type Foo: Ord;). ...(the C-variadic type) may occur syntactically directly as the type of any function parameter.
These are still rejected *semantically*, so you will likely receive an error but these changes can be seen and parsed by procedural macros and conditional compilation.
Compiler
- [Added tier 2\* support for
armv7a-none-eabi.][68253] - [Added tier 2 support for
riscv64gc-unknown-linux-gnu.][68339] - [
Option::{expect,unwrap}andResult::{expect, expect_err, unwrap, unwrap_err}now produce panic messages pointing to the location where they were called, rather thancore's internals. ][67887]
\* Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.
Libraries
- [
iter::Empty<T>now implementsSendandSyncfor anyT.][68348] - [
Pin::{map_unchecked, map_unchecked_mut}no longer require the return type to implementSized.][67935] - [
io::Cursornow derivesPartialEqandEq.][67233] - [
Layout::newis nowconst.][66254] - [Added Standard Library support for
riscv64gc-unknown-linux-gnu.][66899]
Stabilized APIs
- [
CondVar::wait_while] - [
CondVar::wait_timeout_while] - [
DebugMap::key] - [
DebugMap::value] - [
ManuallyDrop::take] - [
matches!] - [
ptr::slice_from_raw_parts_mut] - [
ptr::slice_from_raw_parts]
Cargo
- [You no longer need to include
extern crate proc_macro;to be able touse proc_macro;in the2018edition.][cargo/7700]
Compatibility Notes
Error::descriptionhas been deprecated, and its use will now produce a warning. It's recommended to useDisplay/to_stringinstead.
Release notes from the Rust project's RELEASES.md (MIT or Apache-2.0); summaries above are ours.
Up next
Next releaseRust 1.43Released Apr 23, 2020.Read it next →Also worth your time
Did this answer your question?