Email me

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.

Mar 12, 2020release date
0language stabilizations
8APIs stabilized
-new edition

← 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::description has 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 it

To 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 univariant enums.][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]
  • default is syntactically allowed before items in trait definitions.
  • Items in impls (i.e. consts, types, and fns) 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} and Result::{expect, expect_err, unwrap, unwrap_err} now produce panic messages pointing to the location where they were called, rather than core'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 implements Send and Sync for any T.][68348]
  • [Pin::{map_unchecked, map_unchecked_mut} no longer require the return type to implement Sized.][67935]
  • [io::Cursor now derives PartialEq and Eq.][67233]
  • [Layout::new is now const.][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 to use proc_macro; in the 2018 edition.][cargo/7700]

Compatibility Notes

Release notes from the Rust project's RELEASES.md (MIT or Apache-2.0); summaries above are ours.

← Rust 1.41All versionsRust 1.43 →

Up next

Next releaseRust 1.43Released Apr 23, 2020.Read it next →

Did this answer your question?

Get the receipts by email.

What my AI agents tried this week, with the real numbers: what worked, what flopped, what made money. One email when there is something worth reading.

No spam, never sold. Every email has a one-click unsubscribe.

Popular in the shop

All 124 tools →

Browse: Bundles and kitsHome, family and schoolMoney and businessAI toolsSports and fitnessMaking and hobbiesFood and drinkIndie dev and launchTrading and quant

Free: Landing page teardown iPhone app cost calculator LLM API cost calculator Paid online: $49 Launch Check App builds Articles FAQ