Version 1.51.0 (2021-03-25)
Language
- You can now parameterize items such as functions, traits, and
structs by constant values in addition to by types and lifetimes. Also known as "const generics" E.g. you can now write the following. Note: Only values of primitive integers,bool, orchartypes are currently permitted.#![allow(unused)] fn main() { 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. 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. - Added tier 3 support for
i386-unknown-linux-gnuandi486-unknown-linux-gnutargets. - The
target-cpu=nativeoption will now detect individual features of CPUs.
* 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.strnow implementsAsMut<str>.u64andu128now implementFrom<char>.Erroris now implemented for&TwhereTimplementsError.Poll::{map_ok, map_err}are now implemented forPoll<Option<Result<T, E>>>.unsigned_absis now implemented for all signed integer types.io::Emptynow implementsio::Seek.rc::Weak<T>andsync::Weak<T>'s methods such asas_ptrare now implemented forT: ?Sizedtypes.DivandRemby theirNonZerovariant is now implemented for all unsigned integers.
Stabilized APIs
Arc::decrement_strong_countArc::increment_strong_countOnce::call_once_forcePeekable::next_if_eqPeekable::next_ifSeek::stream_positionarray::IntoIterpanic::panic_anyptr::addr_of!ptr::addr_of_mut!slice::fill_withslice::split_inclusive_mutslice::split_inclusiveslice::strip_prefixslice::strip_suffixstr::split_inclusivesync::OnceStatetask::WakeVecDeque::rangeVecDeque::range_mut
Cargo
- Added the
split-debuginfoprofile option to control the -Csplit-debuginfo codegen option. - Added the
resolverfield toCargo.tomlto enable the new feature resolver and CLI option behavior. 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 for more information on the feature.
Rustdoc
- Rustdoc will now include documentation for methods available from nested
Dereftraits. - You can now provide a
--default-themeflag which sets the default theme to use for documentation.
Various improvements to intra-doc links:
- You can link to non-path primitives such as
slice. - You can link to associated items.
- You can now include generic parameters when linking to items, like
Vec<T>.
Misc
Compatibility Notes
- WASI platforms no longer use the
wasm-bindgenABI, and instead use the wasm32 ABI. rustcno longer promotes division, modulo and indexing operations toconstthat could fail.- The minimum version of glibc for the following platforms has been bumped to version 2.31
for the distributed artifacts.
armv5te-unknown-linux-gnueabisparc64-unknown-linux-gnuthumbv7neon-unknown-linux-gnueabihfarmv7-unknown-linux-gnueabix86_64-unknown-linux-gnux32
atomic::spin_loop_hinthas been deprecated. It's recommended to usehint::spin_loopinstead.