Rust versions / 1.57
Rust release · Dec 2, 2021
Rust 1.57: what's new, what was stabilized
Short answerRust 1.57 was released on Dec 2, 2021: 21 newly stable APIs ([T; N]::as_mut_slice, [T; N]::as_slice, collections::TryReserveError, HashMap::try_reserve, ...); 1 compatibility note that can affect existing code.
← Rust 1.56All versionsRust 1.58 →
21 APIs stabilized
[T; N]::as_mut_slice, [T; N]::as_slice, collections::TryReserveError, HashMap::try_reserve, HashSet::try_reserve, String::try_reserve, String::try_reserve_exact, Vec::try_reserve, Vec::try_reserve_exact, VecDeque::try_reserve, VecDeque::try_reserve_exact, Iterator::map_while, iter::MapWhile, proc_macro::is_available, Command::get_program, Command::get_args, Command::get_envs, Command::get_current_dir, CommandArgs, CommandEnvs, hint::unreachable_unchecked
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:
- [Ignore derived
CloneandDebugimplementations during dead code analysis.][85200]
Use it
rustup update stable # get the newest release
rustup install 1.57 # or exactly this one
rustup override set 1.57 # pin a project to itTo require at least this version from users of your crate, set rust-version = "1.57" 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
- [Macro attributes may follow
#[derive]and will see the original (pre-cfg) input.][87220] - [Accept curly-brace macros in expressions, like
m!{ .. }.method()andm!{ .. }?.][88690] - [Allow panicking in constant evaluation.][89508]
- [Ignore derived
CloneandDebugimplementations during dead code analysis.][85200]
Compiler
- [Create more accurate debuginfo for vtables.][89597]
- [Add
armv6k-nintendo-3dsat Tier 3\*.][88529] - [Add
armv7-unknown-linux-uclibceabihfat Tier 3\*.][88952] - [Add
m68k-unknown-linux-gnuat Tier 3\*.][88321] - [Add SOLID targets at Tier 3\*:][86191]
aarch64-kmc-solid_asp3,armv7a-kmc-solid_asp3-eabi,armv7a-kmc-solid_asp3-eabihf
\* Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.
Libraries
- [Avoid allocations and copying in
Vec::leak][89337] - [Add
#[repr(i8)]toOrdering][89507] - [Optimize
File::read_to_endandread_to_string][89582] - [Update to Unicode 14.0][89614]
- [Many more functions are marked
#[must_use]][89692], producing a warning when ignoring their return value. This helps catch mistakes such as expecting a function to mutate a value in place rather than return a new value.
Stabilized APIs
- [
[T; N]::as_mut_slice][array::as_mut_slice] - [
[T; N]::as_slice][array::as_slice] - [
collections::TryReserveError] - [
HashMap::try_reserve] - [
HashSet::try_reserve] - [
String::try_reserve] - [
String::try_reserve_exact] - [
Vec::try_reserve] - [
Vec::try_reserve_exact] - [
VecDeque::try_reserve] - [
VecDeque::try_reserve_exact] - [
Iterator::map_while] - [
iter::MapWhile] - [
proc_macro::is_available] - [
Command::get_program] - [
Command::get_args] - [
Command::get_envs] - [
Command::get_current_dir] - [
CommandArgs] - [
CommandEnvs]
These APIs are now usable in const contexts:
- [
hint::unreachable_unchecked]
Cargo
- [Stabilize custom profiles][cargo/9943]
Compatibility Notes
- [Ignore derived
CloneandDebugimplementations during dead code analysis.][85200] This will break some builds that set#![deny(dead_code)].
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.
Release notes from the Rust project's RELEASES.md (MIT or Apache-2.0); summaries above are ours.
Up next
Next releaseRust 1.58Released Jan 13, 2022.Read it next →Also worth your time
Did this answer your question?