Rust versions / 1.51
Rust release · Mar 25, 2021
Rust 1.51: what's new, what was stabilized
Short answerRust 1.51 was released on Mar 25, 2021: 20 newly stable APIs (Arc::decrement_strong_count, Arc::increment_strong_count, Once::call_once_force, Peekable::next_if_eq, ...); 4 compatibility notes that can affect existing code.
← Rust 1.50All versionsRust 1.52 →
20 APIs stabilized
Arc::decrement_strong_count, Arc::increment_strong_count, Once::call_once_force, Peekable::next_if_eq, Peekable::next_if, Seek::stream_position, array::IntoIter, panic::panic_any, ptr::addr_of!, ptr::addr_of_mut!, slice::fill_with, slice::split_inclusive_mut, slice::split_inclusive, slice::strip_prefix, slice::strip_suffix, str::split_inclusive, sync::OnceState, task::Wake, VecDeque::range, VecDeque::range_mut
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:
- [WASI platforms no longer use the
wasm-bindgenABI, and instead use the wasm32 ABI.][79998] - [
rustcno longer promotes division, modulo and indexing operations toconstthat - [The minimum version of glibc for the following platforms has been bumped to version 2.31
- [
atomic::spin_loop_hinthas been deprecated.][80966] It's recommended to usehint::spin_loopinstead.
Use it
rustup update stable # get the newest release
rustup install 1.51 # or exactly this one
rustup override set 1.51 # pin a project to itTo require at least this version from users of your crate, set rust-version = "1.51" 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 parameterize items such as functions, traits, and
structs by constant values in addition to by types and lifetimes.][79135] Also known as "const generics" E.g. you can now write the following. Note: Only values of primitive integers,bool, orchartypes are currently permitted. ```rust struct GenericArray<T, const LENGTH: usize> { inner: [T; LENGTH] }
impl<T, const LENGTH: usize> GenericArray<T, LENGTH> { const fn last(&self) -> Option<&T> { if LENGTH == 0 { None } else { Some(&self.inner[LENGTH - 1]) } } } ```
Compiler
- [Added the
-Csplit-debuginfocodegen option for macOS platforms.][79570] This option controls whether debug information is split across multiple files or packed into a single file. **Note** This option is unstable on other platforms. - [Added tier 3\* support for
aarch64_be-unknown-linux-gnu,aarch64-unknown-linux-gnu_ilp32, andaarch64_be-unknown-linux-gnu_ilp32targets.][81455] - [Added tier 3 support for
i386-unknown-linux-gnuandi486-unknown-linux-gnutargets.][80662] - [The
target-cpu=nativeoption will now detect individual features of CPUs.][80749]
\* Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.
Libraries
- [
Box::downcastis now also implemented for anydyn Any + Send + Syncobject.][80945] - [
strnow implementsAsMut<str>.][80279] - [
u64andu128now implementFrom<char>.][79502] - [
Erroris now implemented for&TwhereTimplementsError.][75180] - [
Poll::{map_ok, map_err}are now implemented forPoll<Option<Result<T, E>>>.][80968] - [
unsigned_absis now implemented for all signed integer types.][80959] - [
io::Emptynow implementsio::Seek.][78044] - [
rc::Weak<T>andsync::Weak<T>'s methods such asas_ptrare now implemented forT: ?Sizedtypes.][80764] - [
DivandRemby theirNonZerovariant is now implemented for all unsigned integers.][79134]
Stabilized APIs
- [
Arc::decrement_strong_count] - [
Arc::increment_strong_count] - [
Once::call_once_force] - [
Peekable::next_if_eq] - [
Peekable::next_if] - [
Seek::stream_position] - [
array::IntoIter] - [
panic::panic_any] - [
ptr::addr_of!] - [
ptr::addr_of_mut!] - [
slice::fill_with] - [
slice::split_inclusive_mut] - [
slice::split_inclusive] - [
slice::strip_prefix] - [
slice::strip_suffix] - [
str::split_inclusive] - [
sync::OnceState] - [
task::Wake] - [
VecDeque::range] - [
VecDeque::range_mut]
Cargo
- [Added the
split-debuginfoprofile option to control the -Csplit-debuginfo codegen option.][cargo/9112] - [Added the
resolverfield toCargo.tomlto enable the new feature resolver and CLI option behavior.][cargo/8997] Version 2 of the feature resolver will try to avoid unifying features of dependencies where that unification could be unwanted. Such as using the same dependency with astdfeature in a build scripts and proc-macros, while using theno-stdfeature in the final binary. See the [Cargo book documentation][feature-resolver@2.0] for more information on the feature.
Rustdoc
- [Rustdoc will now include documentation for methods available from _nested_
Dereftraits.][80653] - [You can now provide a
--default-themeflag which sets the default theme to use for documentation.][79642]
Various improvements to intra-doc links:
- [You can link to non-path primitives such as
slice.][80181] - [You can link to associated items.][74489]
- [You can now include generic parameters when linking to items, like
Vec<T>.][76934]
Misc
- [You can now pass
--include-ignoredto tests (e.g. withcargo test -- --include-ignored) to include testing tests marked#[ignore].][80053]
Compatibility Notes
- [WASI platforms no longer use the
wasm-bindgenABI, and instead use the wasm32 ABI.][79998] - [
rustcno longer promotes division, modulo and indexing operations toconstthat could fail.][80579] - [The minimum version of glibc for the following platforms has been bumped to version 2.31 for the distributed artifacts.][81521]
armv5te-unknown-linux-gnueabisparc64-unknown-linux-gnuthumbv7neon-unknown-linux-gnueabihfarmv7-unknown-linux-gnueabix86_64-unknown-linux-gnux32- [
atomic::spin_loop_hinthas been deprecated.][80966] It's recommended to usehint::spin_loopinstead.
Internal Only
Release notes from the Rust project's RELEASES.md (MIT or Apache-2.0); summaries above are ours.
Up next
Next releaseRust 1.52Released May 6, 2021.Read it next →Also worth your time
Did this answer your question?