Email me

Rust versions / 1.46

Rust release · Aug 27, 2020

Rust 1.46: what's new, what was stabilized

Short answerRust 1.46 was released on Aug 27, 2020: 2 newly stable APIs (Option::zip, vec::Drain::as_slice); 11 compatibility notes that can affect existing code.

Aug 27, 2020release date
0language stabilizations
2APIs stabilized
-new edition

← Rust 1.45All versionsRust 1.47 →

2 APIs stabilized

Option::zip, vec::Drain::as_slice

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:

  • [The target configuration option abi_blacklist has been renamed
  • [Rustc will now warn if you cast a C-like enum that implements Drop.][72331]
  • [Rustc will fail to compile if you have a struct with
  • [Tokens passed to macro_rules! are now always captured.][73293] This helps
  • [The InnoSetup installer for Windows is no longer available.][72569] This was
  • [{f32, f64}::asinh now returns the correct values for negative numbers.][72486]
  • [Rustc will no longer accept overlapping trait implementations that only
  • [Rustc now correctly relates the lifetime of an existential associated
  • [Rustc now dynamically links to libz (also called zlib) on Linux.][74420]
  • [Tests annotated with #[should_panic] are broken on ARMv7 while running
  • [Pretty printing of some tokens in procedural macros changed.][75453] The

Use it

rustup update stable        # get the newest release
rustup install 1.46          # or exactly this one
rustup override set 1.46     # pin a project to it

To require at least this version from users of your crate, set rust-version = "1.46" 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

  • [if, match, and loop expressions can now be used in const functions.][72437]
  • [Additionally you are now also able to coerce and cast to slices (&[T]) in const functions.][73862]
  • [The #[track_caller] attribute can now be added to functions to use the function's caller's location information for panic messages.][72445]
  • [Recursively indexing into tuples no longer needs parentheses.][71322] E.g. x.0.0 over (x.0).0.
  • [mem::transmute can now be used in statics and constants.][72920] **Note** You currently can't use mem::transmute in constant functions.

Compiler

  • [You can now use the cdylib target on Apple iOS and tvOS platforms.][73516]
  • [Enabled static "Position Independent Executables" by default for x86_64-unknown-linux-musl.][70740]

Libraries

  • [mem::forget is now a const fn.][73887]
  • [String now implements From<char>.][73466]
  • [The leading_ones, and trailing_ones methods have been stabilised for all integer types.][73032]
  • [vec::IntoIter<T> now implements AsRef<[T]>.][72583]
  • [All non-zero integer types (NonZeroU8) now implement TryFrom for their zero-able equivalent (e.g. TryFrom<u8>).][72717]
  • [&[T] and &mut [T] now implement PartialEq<Vec<T>>.][71660]
  • [(String, u16) now implements ToSocketAddrs.][73007]
  • [vec::Drain<'_, T> now implements AsRef<[T]>.][72584]

Stabilized APIs

  • [Option::zip]
  • [vec::Drain::as_slice]

Cargo

Added a number of new environment variables that are now available when compiling your crate.

  • [CARGO_BIN_NAME and CARGO_CRATE_NAME][cargo/8270] Providing the name of the specific binary being compiled and the name of the crate.
  • [CARGO_PKG_LICENSE][cargo/8325] The license from the manifest of the package.
  • [CARGO_PKG_LICENSE_FILE][cargo/8387] The path to the license file.

Compatibility Notes

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

← Rust 1.45All versionsRust 1.47 →

Up next

Next releaseRust 1.47Released Oct 8, 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