Version 1.54.0 (2021-07-29)
Language
-
You can now use macros for values in some built-in attributes. 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:#![allow(unused)] #![doc = include_str!("README.md")] fn main() { } -
You can now cast between unsized slice types (and types which contain unsized slices) in
const fn. -
You can now use multiple generic lifetimes with
impl Traitwhere the lifetimes don't explicitly outlive another. 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. You can find your sysroot directory by runningrustc --print sysroot. - Added
wasmas atarget_familyfor WebAssembly platforms. - You can now use
#[target_feature]on safe functions when targeting WebAssembly platforms. - Improved debugger output for enums on Windows MSVC platforms.
- Added tier 3* support for
bpfel-unknown-noneandbpfeb-unknown-none. -Zmutable-noalias=yesis 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].- Added
OutOfMemoryas a variant ofio::ErrorKind. -
proc_macro::Literalnow implementsFromStr. - The implementations of vendor intrinsics in core::arch have been significantly refactored. 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_keysBTreeMap::into_valuesHashMap::into_keysHashMap::into_valuesarch::wasm32VecDeque::binary_searchVecDeque::binary_search_byVecDeque::binary_search_by_keyVecDeque::partition_point
Cargo
- Added the
--prune <spec>option tocargo-treeto remove a package from the dependency graph. - Added the
--depthoption tocargo-treeto print only to a certain depth in the tree - Added the
no-proc-macrovalue tocargo-tree --edgesto hide procedural macro dependencies. - A new environment variable named
CARGO_TARGET_TMPDIRis available. 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.