Rust Language

What’s new in Rust 1.72

Rust was designed to make it easy to develop fast and safe system-level software. Here’s what’s new.

What’s new in the Rust programming language
Gratisography (CC0)

The unique approach of the Rust programming language results in better code with fewer compromises than C, C++, Go, and the other languages you probably use. It also gets updated regularly, often every month.

Where to download the latest Rust version

If you already have a previous version of Rust installed via rustup, you can access the latest version via the following command:

$ rustup update stable

The new features in Rust 1.72.0

Announced August 24, Rust 1.72.0 lets developers conditionally enable code using the cfg operator, for configuration conditional checks, to provide certain functions only with certain crate features or only on particular platforms. Previously, items disabled like this effectively would be invisible to the compiler. With Rust 1.72.0, the compiler will remember the name and cfg conditions of those items. It could report, for example, if a function a developer tried to call is unavailable because a crate feature must be enabled.

Also in Rust 1.72.0, const evaluation time now is unlimited. Rust previously limited the maximum number of statements run as a part of any given constant evaluation, to prevent user-provided const evaluation from getting into a compile-time infinite loop or otherwise taking unbounded time at compile. Developers now can do an unlimited amount of const evaluation at compile time. 

Elsewhere in Rust 1.72.0, several lints from Clippy have been pulled into rustc. And a number of APIs have been stabilized including CStr::from_bytes_with_nul and CStr::to_Bytes.

In a future release, the Rust development team plans to increase the minimum-supported Windows version to Windows 10. Rust 1.75 is slated to be the last Rust version to officially support Windows 7, Windows 8, and Windows 8.1.

Rust 1.72.0 follows Rust 1.71.1 from August 3, which fixed a situation in which the Cargo package manager was not respecting the unmask when extracting dependencies, which could have enabled a local attacker to edit the cache of extracted source code of another user. Rust 1.71.1 also addressed several regressions introduced in Rust 1.71.0, including Bash completion being broken for users of the Rustup toolchain installer.

The new features in Rust 1.71.0

Rust 1.71.0 was introduced on July 13. With this version, Rust on Windows platforms supports using functions from dynamic libraries without requiring those libraries to be available at build time, using a new kind="raw-dylib”" option for #[link]. This saves users from having to install those libraries, which is particularly an issue for cross-compilation, and avoids having to ship stub versions of libraries in crates to link against. Rust 1.71.0 also supports binding symbols provided by DLLs by ordinal rather than named symbol, via a new #link_ordinal attribute.

Also new and improved in Rust 1.71.0:

  • For debugging visualization, support is stabilized for a new attribute, #[debug_visualizer(natvis_file = "...")] and #[debug_visualizer(gdb_script_file = "...")], that allows embedding Natvis XML framework descriptions and GDB scripts into Rust libraries to improve debugger output when inspecting data structures created by those libraries. Rust has packaged similar scripts for some time for the standard library. This feature makes it possible for library writers to provide a similar experience to users.
  • Rust 1.71.0 stabilizes c-unwind and other -unwind suffixed ABI variants. Each ABI is the equivalent of the same ABI without -unwind, except that with -unwind the behavior is defined to be safe when an unwinding operation (a panic or C++ style exception) crosses the ABI boundary. For panic-unwind, this is a valid way to let exceptions from one language unwind the stack in another language without terminating the process, as long as the exception is caught in the same language from which it originated. For panic=abort, this typically will abort the process immediately. For this initial stabilization, no change is made to existing ABIs; unwinding across them remains undefined behavior. A future Rust release will amend these ABIs to match the behavior specified in a related RFC as the final part of stabilizing this feature, usually aborting at the boundary. Developers are encouraged to start using new unwind ABI variants in their code to remain future-proof if they must unwind across the ABI boundary.
  • Various *-linux-musl targets will ship with musl 1.2.3, an implementation of the C standard library built atop the Linux system call API. Most users are not expected to be affected by this.
  • Several APIs have been stabilized such as CStr::is_empty and BuildHasher::hash_one.

The new features in Rust 1.70

Debuting June 1, 2023, Rust 1.70 enables by default the “sparse” protocol for Cargo for reading the index from crates.io. This feature had been stabilized in Rust 1.68 but using it with crates.io still required configuration. Users should see substantially improved performance when fetching information from crates.io index.

Also in Rust 1.70, two types have been stabilized for one-time initialization of shared data: OnceCell and its thread-safe counterpart, OnceLock. These can be used anywhere that immediate construction is not wanted and perhaps not even possible, such as non-const data in global variables.

A newly stabilized IsTerminal trait has a single method to determine if a given file descriptor or handle represents a terminal or TTY. This is another case of standardizing functionality that existed in external traits, such as atty and is-terminal, using the C library isatty function on Unix targets and similar functionality elsewhere. Version 1.70 also supports named levels of debug information. Stable and beta builds of Rust no longer will allow unstable test options, making them truly nightly-only, as documented. Rust 1.70 also stabilizes a number of APIs, such as NonZero*::MIN/MAX and BinaryHeap::retain.

The new features in Rust 1.69

Announced April 20, 2023, Rust 1.69 offers no new major features but contains many small improvements, including more than 3,000 commits from more than 500 contributors, the Rust release team said.

Rust 1.29 introduced the cargo fix subcommand to automatically fix some simple compiler warnings. Since then, the number of warnings that can be fixed automatically has continued to increase. Additionally, support for automatically fixing some simple Clippy warnings has been added. To draw attention to these capabilities, Cargo now will suggest running cargo fix or cargo clippy --fix when it detects warnings that are automatically fixable:

warning: unused import: `std::hash::Hash`
--> src/main.rs:1:5
|
1| use std::hash::Hash;
|     ^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default

warning: `foo` (bin "foo") generated 1 warning (run `cargo fix --bin "foo"` to apply 1 suggestion)

The full Cargo invocation shown here only is necessary to precisely apply fixes to a single crate. To apply fixes to all default members of a workspace, running cargo fix with no additional arguments is all that’s necessary.

Also in Rust 1.69, debug information is no longer included in build scripts by default. To boost compilation speed, Cargo now avoids emitting debug information in build scripts by default. There will be no visible effect when build scripts execute successfully. Finally, a number of APIs have been stabilized such as cstr::from_bytes_until_nul and core::ffi::FromBytesUntilNulError.

The new features in Rust 1.68

Rust 1.68.0, announced March 9, stabilizes the “sparse” registry protocol for the Cargo package manager for reading the index of crates, along with infrastructure at http//index.crates.io/ for those published in the primary crates.io registry. The previous Git protocol, still the default, clones a repository that indexes all crates available in the registry. However, the Git protocol has begun to hit scaling limitations, with delays while updating the repository. The new protocol is expected to improve performance when accessing crates.io.

To use the sparse protocol with crates.io, set the environment variable CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse, or edit your .cargo/config/toml file to add:

[registries.crates-io]protocol = "sparse"

The sparse protocol is set to become the default for crates.io in Rust 1.70.0, which is due in a few months.

Elsewhere in Rust 1.68.0, a new pin! macro constructs a Pin<&mut T> from a T expression, anonymously captured in local state. This often is called stack pinning, but that “stack” also could be the captured state of an async fn or block. This macro is similar to some crates, but the standard library can leverage Pin internals and temporary lifetime extension for a more expression-like macro.

Finally, Rust 1.68.0 stabilizes some APIs including {core, std}::pin::pin! and impl DerefMut for PathBuf. And Android platform support in Rust now targets NDK r25 toolset.

The new features in Rust 1.67

Rust 1.67, unveiled January 26, adds a compiler warning pertaining to #[must_use] and async fn. In Rust, async functions annotated with #[must_use] now apply that attribute to the output of the returned impl Future. The Future trait already is annotated with #[must_use], so types implementing [Future] are automatically #[must_use]. Previously there was no way to indicate that the output of the Future is itself significant and should be used in some way. In Rust 1.67, the compiler now will warn if the output is not used.

Also in Rust 1.67, the implementation of the multi-producer, single-consumer channel of the standard library has been updated. Rust’s standard library has had a multi-producer, single-consumer channel since before version 1.0. With Rust 1.67, the implementation has been switched out to be based on crossbeam-channel. The release contains no API changes but the new implementation fixes bugs and improves performance and maintainability of the implementation.

Rust 1.67 stabilizes several APIs such as {integer}::checked_ilog, {integer}::ilog, and NonZero*::BITS. A number of other APIs are now stable in const contexts including char::from_u32, char::from_digit, and char::to_digit. And invalid literals no longer are an error under cfg(FALSE).

Note: Rust 1.66.1 stable, released January 10, fixed a situation in which the Cargo package manager was not verifying SSH host keys when cloning dependencies or registry indexes with SSH. This vulnerability was tracked at cve.org, with more information in the advisory.

The new features in Rust 1.66

Introduced December 15, 2022, Rust 1.66 enables enums with integer representations to now use explicit discriminants, even when they have fields. Previously, developers could use explicit discriminants on enums with representations, but only if none of their variants had fields. Explicit discriminants are useful when passing values across language boundaries where the representation of the enum must match in both languages.

Also in Rust 1.66:

  • A newly stabilized black_box function takes a passed value and passes it right back. The compiler treats black_box as a function that could do anything with its input and return any value. This is useful for disabling optimizations when you don’t want them to occur, such as during benchmarking or when examining the machine code the compiler produces.
  • Developers can use cargo remove to remove dependencies. Rust 1.62 introduced cargo add, a command line utility to add dependencies to a project.
  • Developers now can use ..=x ranges in patterns.
  • Linux builds now optimize the rustc front end and LLVM back end with LTO and BOLT, respectively, improving runtime performance and memory usage.
  • APIs have been stabilized such as proc_macro::Span::source_text and Option::unzip.

The new features in Rust 1.65

Rust 1.65 was introduced November 3, 2022. With this release, generic associated types (GATs), a highly anticipated feature that has been in the works for several years, are finally introduced. GATs allow developers to define lifetime, type, and const generics on associated types. GATs enable patterns that were not previously possible in Rust.

Also in Rust 1.65:

  • A new type of let statement is introduced, let-else, with a refutable pattern and a diverging else block that executes when that pattern does not match.
  • Plain block expressions now can be labeled as a break target, terminating that block early.
  • To improve compilation, support for splitting debug information is now stable for use on Linux, after being supported on macOS since Rust 1.51. With this capability, -Csplit-debuginfo=unpacked will split debuginfo into multiple .dwo DWARF object files, while -Csplit-debuginfo=packed will produce a single .dwp DWARF package along with an output binary with all debuginfo packaged together.
  • APIs have been stabilized such as std::backtrace::Backtrace, Bound::as ref, and std::io::read_to_string.
  • MIR (mid-level intermediate representation) inlining now is enabled for optimized compilations, improving compile times for real world crates.
  • When scheduling builds, Cargo now sorts the queue of pending jobs, improving performance.

The new features in Rust 1.64

1 2 3 4 5 Page 1
Page 1 of 5