1.54.0
版本发布时间: 2021-07-29 22:17:22
rust-lang/rust最新发布版本:1.82.0(2024-10-18 00:44:34)
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:#![doc = include_str!("README.md")]
-
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 Trait
where 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.json
where/
is the "sysroot" directory. You can find your sysroot directory by runningrustc --print sysroot
. -
Added
wasm
as atarget_family
for 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-none
andbpfeb-unknown-none
. -
-Zmutable-noalias=yes
is enabled by default when using LLVM 12 or above.
* Refer to Rust's platform support page for more information on Rust's tiered platform support.
Libraries
-
panic::panic_any
will now#[track_caller]
. -
Added
OutOfMemory
as a variant ofio::ErrorKind
. -
proc_macro::Literal
now 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_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-tree
to remove a package from the dependency graph. -
Added the
--depth
option tocargo-tree
to print only to a certain depth in the tree -
Added the
no-proc-macro
value tocargo-tree --edges
to hide procedural macro dependencies. -
A new environment variable named
CARGO_TARGET_TMPDIR
is 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::arch
intrinsics now uses stricter const checking than before and may reject some previously accepted code. -
i128
multiplication on Cortex M0+ platforms currently unconditionally causes overflow when compiled withcodegen-units = 1
.