Rust versions / 1.54
Rust release · Jul 29, 2021
Rust 1.54: what's new, what was stabilized
Short answerRust 1.54 was released on Jul 29, 2021: 9 newly stable APIs (BTreeMap::into_keys, BTreeMap::into_values, HashMap::into_keys, HashMap::into_values, ...); 4 compatibility notes that can affect existing code.
← Rust 1.53All versionsRust 1.55 →
9 APIs stabilized
BTreeMap::into_keys, BTreeMap::into_values, HashMap::into_keys, HashMap::into_values, arch::wasm32, VecDeque::binary_search, VecDeque::binary_search_by, VecDeque::binary_search_by_key, VecDeque::partition_point
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:
- [Mixing Option and Result via
?is no longer permitted in closures for inferred types.][86831] - [Previously unsound code is no longer permitted where different constructors in branches
- As previously mentioned the [
std::archintrinsics now uses stricter const checking][83278] - [
i128multiplication on Cortex M0+ platforms currently unconditionally causes overflow
Use it
rustup update stable # get the newest release
rustup install 1.54 # or exactly this one
rustup override set 1.54 # pin a project to itTo require at least this version from users of your crate, set rust-version = "1.54" 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 macros for values in some built-in attributes.][83366] This primarily allows you to call macros within the
#[doc]attribute. For example, to include external documentation in your crate, you can now write the following: ``rust #![doc = include_str!("README.md")]``
- [You can now cast between unsized slice types (and types which contain unsized slices) in
const fn.][85078] - [You can now use multiple generic lifetimes with
impl Traitwhere the lifetimes don't explicitly outlive another.][84701] In code this means that you can now haveimpl Trait<'a, 'b>where as before you could only haveimpl Trait<'a, 'b> where 'b: 'a.
Compiler
- [Rustc will now search for custom JSON targets in
/lib/rustlib/<target-triple>/target.jsonwhere/is the "sysroot" directory.][83800] You can find your sysroot directory by runningrustc --print sysroot. - [Added
wasmas atarget_familyfor WebAssembly platforms.][84072] - [You can now use
#[target_feature]on safe functions when targeting WebAssembly platforms.][84988] - [Improved debugger output for enums on Windows MSVC platforms.][85292]
- [Added tier 3\* support for
bpfel-unknown-noneandbpfeb-unknown-none.][79608] - [
-Zmutable-noalias=yes][82834] is enabled by default when using LLVM 12 or above.
\* Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.
Libraries
- [
panic::panic_anywill now#[track_caller].][85745] - [Added
OutOfMemoryas a variant ofio::ErrorKind.][84744] - [
proc_macro::Literalnow implementsFromStr.][84717] - [The implementations of vendor intrinsics in core::arch have been significantly refactored.][83278] The main user-visible changes are a 50% reduction in the size of libcore.rlib and stricter validation of constant operands passed to intrinsics. The latter is technically a breaking change, but allows Rust to more closely match the C vendor intrinsics API.
Stabilized APIs
- [
BTreeMap::into_keys] - [
BTreeMap::into_values] - [
HashMap::into_keys] - [
HashMap::into_values] - [
arch::wasm32] - [
VecDeque::binary_search] - [
VecDeque::binary_search_by] - [
VecDeque::binary_search_by_key] - [
VecDeque::partition_point]
Cargo
- [Added the
--prune <spec>option tocargo-treeto remove a package from the dependency graph.][cargo/9520] - [Added the
--depthoption tocargo-treeto print only to a certain depth in the tree ][cargo/9499] - [Added the
no-proc-macrovalue tocargo-tree --edgesto hide procedural macro dependencies.][cargo/9488] - [A new environment variable named
CARGO_TARGET_TMPDIRis available.][cargo/9375] This variable points to a directory that integration tests and benches can use as a "scratchpad" for testing filesystem operations.
Compatibility Notes
- Mixing Option and Result via
?is no longer permitted in closures for inferred types. - Previously unsound code is no longer permitted where different constructors in branches could require different lifetimes.
- As previously mentioned the
std::archintrinsics now uses stricter const checking than before and may reject some previously accepted code. i128multiplication on Cortex M0+ platforms currently unconditionally causes overflow when compiled withcodegen-units = 1.
Release notes from the Rust project's RELEASES.md (MIT or Apache-2.0); summaries above are ours.
Up next
Next releaseRust 1.55Released Sep 9, 2021.Read it next →Also worth your time
Did this answer your question?