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.

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

Rust 1.64.0, unveiled September 22, 2022, stabilizes the IntoFuture trait, to enhance .await and improve APIs. IntoFuture is similar to the IntoIterator trait, but instead of supporting for … in … loops, IntoFuture changes how .await works.

With IntoFuture, the .await keyword can await more than just features; it can await anything that can be converted into a Future via IntoFuture, to help make APIs more user-friendly. For the future, the developers of Rust hope to simplify development of new named futures by supporting impl Trait in type aliases. This should make implementing IntoFuture easier by simplifying the type alias signature and make it more performant by removing the Box from the type alias.

Also in Rust 1.64:

  • The language provides all c_* type aliases in core::ffi, as well as core::ffi::CStr, for working with C strings. Rust 1.64 also provides alloc::ffi::CString for working with owned C strings using only the alloc crate rather than the full std library.
  • rust-analyzer, an implementation of the Language Server protocol for Rust, now is included as part of the collection of tools included with Rust. This makes it easier to download and access rust-analyzer and makes it available on more platforms. The tool is available as a rustup component and can be installed with the command rustup component add rust_analyzer.
  • When working with collections of related libraries or binary crates in one Cargo workspace, developers now can avoid duplication of common field values between crates, such as common version numbers or repository URLs.
  • The memory layouts of Ipv6Addr, Ipv4Addr, SocketAddrV4, and SocketAddrV6 have been changed to be more memory efficient and compact.
  • Windows builds of the Rust compiler now use profile-guided optimization, improving performance.
  • A number of methods and trait implementations have been stabilized, including num::NonZero*::checked_mul, num::NonZero*::checked_pow, and many others.

The new features in Rust 1.63

Published August 11, 2022, Rust 1.63 adds scoped threads to the standard library. Scoped threads allow you to spawn a thread by borrowing from the local stack frame. The std::thread::scope API provides a guarantee that any spawned threads will have exited prior to its returning, allowing for safely borrowing data. Rust 1.63 also enables non-lexical lifetimes (NLL) by default; the feature is now fully stable. NLL is the second iteration of Rust’s borrow checker.

Also in Rust 1.63:

  • For I/O safety, wrapper types are provided such as BorrowedFD and OwnedFD, which are marked as #[repr(transparent)], meaning that extern "C" bindings can take these types to encode ownership semantics.
  • The Condvar::New, Mutex::New, and RwLock::new functions are now callable in const contexts, to avoid the use of crates such as lazy_static for creating global statics with Mutex, RwLock, or Condvar. This builds on work in Rust 1.62 to enable faster and thinner mutexes.
  • A number of APIs were stabilized including array::from_fn, Box::into_pin, and Path::try_exists.

The new features in Rust 1.62

Rust 1.62, which arrived June 30, 2022, lets developers add dependencies directly from the command line using cargo add. This command supports specifying versions and features and also can modify existing dependencies. Rust 1.62 also allows the use of #[derive(Default)] on enums if a default variant is specified.

Other new capabilities in Rust 1.62:

  • Rust’s standard library now ships with a raw futex-based implementation of locks on Linux, which is lightweight and does not carry any extra allocation. This addition is part of an effort to improve the efficiency of Rust lock types.
  • It is now easier to build OS-less binaries for x86_64, for example when writing a kernel. The x86_64-unknown-none target has been promoted to Tier 2 and can be installed with rustup.
  • A number of APIs have been stabilized including bool::then_some, f32::total_cmp, f64::total_cmp, and Stdin::lines.

The new features in Rust 1.61

Published May 19, 2022, Rust 1.61 highlights custom exit codes from main. Rust proponents said that in the beginning, Rust main functions only could return the unit type () either implicitly or explicitly, indicating success in the exit status, and if developers wanted otherwise, they had to call process::exit. Since Rust 1.26, main has been allowed to return a Result, where Ok translated to a C EXIT_SUCCESS and Err to EXIT_Failure. These alternate return types were unified by an unstable Termination trait. In this release, Termination trait is stable, along with a more-general ExitCode type that wraps platform-specific return types. The Termination trait also can be implemented for a developer’s own types, allowing for customization of reporting before converting to an ExitCode.

Also in Version 1.61:

  • Several incremental features have been stabilized to enable more functionality in const. Developers now can create, pass, and cast function pointers in a const fn, which could be useful to build compile-time function tables for an interpreter. But it is still not permitted to call fn pointers. Developers also now can write trait bounds on generic parameters to const fn, such as T: Copy, where previously only Sized was permitted. Also, const fn now can deal with trait objects, whereas arguments and return values for const fn can be opaque impl Trait types.
  • APIs have been stabilized such as Pin::static_mut, Pin;;static_ref, and Vec::retain_mut.
  • Previously, the creation of locked handles to stdin/stdlout/stderr would borrow the handles being locked, which prevented writing let out = std::io::stdout().lock(); because out would outlive the return value of stdout(). This code now works, eliminating a common pitfall affecting many Rust users.

The new features in Rust 1.60.0

Rust 1.60, introduced April 7, 2022, stabilizes support for LLVM-based coverage instrumentation in rustc. This provides for source-based code coverage. Developers can try this out by rebuilding their code with -Cinstrument-coverage. Afterward, running the resulting binary will produce a default.profraw file in the current directory.

The llvm-tools-preview component includes llvm-profdata for processing and merging raw profile output, llvm-profdata for processing raw file output, and llvm-cov for report generation. Baseline functionality is stable and will exist in all future Rust releases, but the specific output format and LLVM tools that produce it are subject to change. Developers should use the same version for both llvm-tools-preview and the rustc binary used to compile code.

Rust 1.60 also re-enables incremental compilation. The Rust team continues to work on fixing bugs in incremental but no problems causing widespread breakage are known at this time.

 Also in Rust 1.60:

  • On all platforms, Instant will try to use an operating system API that guarantees monotonic behavior if available. In practice, such guarantees are, under rare circumstances, broken by hardware, virtualization, or operating system bugs. To work around these bugs, and to work with platforms that lack monotonic clocks, Instant::duration_since, Instant::elapsed, and Instant::sub now saturate to zero. In older versions of Rust, this led to a panic, instead.
  • Cargo has established support for collecting information on build with the --timings flag.
  • Namespaced dependencies and weak dependency features have been introduced to improve support for Cargo features and how they interact with optional dependencies. Cargo features provide a mechanism to express conditional compilation and optional dependencies.
  • A number of APIs have been stabilized such as Arc::new_cyclic, Rc::new_cyclic, and slice::EscapAscii.

The new features in Rust 1.59.0

Rust 1.59.0 was announced on February 24, 2022. A key feature is support for inline assembly, enabling many applications that need very low-level control over execution or access to specialized machine instructions. Assembly language and instructions available with inline assembly vary according to architecture. The capability currently is supported on architectures including x86 and x64, ARM, Risc-V, and AArch64. 

Other new features and improvements in Rust 1.59.0:

  • Developers now can use slice, tuple, and struct patterns as the left-hand side of an assignment, making assignment more consistent with let bindings, which already support these patterns.
  • Generic types now can specify default values for const generics.
  • The Cargo package manager now shows warnings when a dependency will be rejected by a future version of Rust.
  • For the creation of stripped binaries, cargo and rustc now support stripping when the binary is linked. Rust’s developers said it is often useful to strip unnecessary information like buginfo from binaries that are distributed, making them smaller.
  • Incremental compilation is off by default. This mitigates the effect of a known bug that causes deserialization errors. A fix for this bug will be available in the Rust 1.60 beta due in six weeks.
  • A number of APIs have been stabilized.

The new features in Rust 1.58.1

This point release arriving January 20, 2022, just days after Rust 1.58, fixes a race condition in the std::fs::remove_dir_all standard library function. This vulnerability is tracked at CVE-2022-21658 and there was an advisory published. An attacker could use this security issue to trick a privileged program into deleting files and directories that the attacker otherwise could not access or delete. Rust versions 1.0 through 1.58 are affected by this vulnerability. Users are advised to update their toolchains and build programs with the updated compiler.

Rust 1.58.1 also addresses several regressions in diagnostics and tools introduced in Rust 1.58:

  • The non_send_fields_in_send_ty Clippy lint was found to have too many false positives and has been moved to the experimental lints group called “nursery”.
  • The useless_format Clippy lint was updated to handle captured identifiers in format strings, introduced in Rust 1.58.
  • A regression in Rustfmt preventing generated files from being formatted when passed through the standard input has been fixed.
  • An incorrect error message displayed by rustc in some cases has been fixed.

The new features in Rust 1.58

Rust 1.58, announced January 13, 2022, features captured identifiers in format strings. With this capability, format strings now can capture arguments by writing {ident} in the string. Formats long have accepted positional arguments and named arguments, such as:

println!("Hello, {}!", get_person());     // implicit position
println!("Hello, {0}!", get_person());     // explicit index
println!("Hello, {person}!", person = get_person());     // named

Now, named arguments also can be captured from the surrounding scope.

Also new in Rust 1.58: On Windows targets, std::process::Command will no longer search the current directory for executables, which was an effect of the historical behavior of the win32 CreateProcess API. This fixes a situation in which searches could lead to surprising behavior or malicious results when dealing with untrusted directories. 

Rust 1.58 also introduces more #[must_use] in the standard library. The #[must use] attribute can be applied to types or functions when failing to explicitly consider them or their output is almost certainly a bug. Rust 1.58 also has stabilized APIs such as Metadata::is_symlinkcode and Path::is_symlink.

The new features in Rust 1.57

Rust 1.57, unveiled December 2, 2021, brings panic! (for terminating a program in an unrecoverable state) to const contexts. Previously, the panic! macro was not usable in const fn and other compile-time contexts. This has now been stabilized. Together with the stabilization of panic!, several other standard libraries now are usable in const, such as assert!. But this stabilization does not yet include the full formatting infrastructure. The panic! macro must be called with either a static string or a single interpolated value to be used with {}. This support is expected to expand in the future.

Other new features and improvements in Rust 1.57:

  • Cargo adds support for arbitrarily named profiles.
  • try_reserve has been stabilized for Vec, String, HashMap, HashSet, and VecDeque. This API enables callers to fallibly allocate backing storage for these types.
  • Multiple other APIs have been stabilized including [T; N]::as_mut_slice and [T; N]::as_slice.
  • Macro attributes now may follow #derive and will see the original input.

The new features in Rust 1.56

Announced October 21, 2021, Rust 1.56 is the first version of the language that supports the Rust 2021 edition. The Rust 2021 edition lets Rust crate authors opt in to breaking language changes that make Rust easier to use and more consistent. Crates can opt in at any time and remain interoperable with crates in older editions. The Rust compiler supports all three editions of the language: 2015, 2018, and 2021.

Other new capabilities in Rust 1.56 include:

  • Disjoint capture in closures, to simplify the writing of closures.
  • Cargo.toml now supports a [package] [rust-version] field to specify the minimum supported Rust version for a crate, and Cargo will exit with an early error if that is not satisfied. While this currently does not influence the dependency resolver, the intent is catch compatibility problems before they turn into cryptic compiler errors.
  • New bindings in binding@pattern are supported. Rust pattern matching can be written with a single identifier that binds the entire value, followed by @ and a more-refined structural pattern, but has not allowed additional bindings in that pattern until now. This functionality had been permitted prior to Rust 1.0, but was removed due to unsoundness. The compiler team now has determined that this pattern is safe and allowable in stable Rust.
  • Panic macros now always expect format strings, just like printlin!().
  • A number of APIs have been stabilized including std::os::unix::fs::chroot and UnsafeCell::raw_get.

The new features in Rust 1.55

Announced September 9, 2021, Rust 1.55 offers faster, more correct float parsing. The standard library implementation of float parsing has been updated to use the Eisel-Lemire algorithm, which brings improvements in speed and correctness. Previously, certain edge cases failed to parse, but these have now been fixed.

Also in Rust 1.55:

  • The use of open ranges in patterns has been stabilized.
  • A number of methods and trait implementations have been stabilized including Bound::cloned and Drain::as_str.
  • Cargo now deduplicates compiler errors and prints a report at the end of compilation. Previously, when running cargo test, cargo check ---all targets, or similar commands that built the same Rust crate in multiple configurations, errors and warnings might show up duplicated as the rustc executions were run in parallel and showed the same warning.

The new features in Rust 1.54

Published July 29, 2021, Rust 1.54 supports invoking function-like macros inside attributes. Function-like macros can be macros based on macro-rules! or they can be procedural macros, which are invoked like macro!(…). A notable use case is including documentation from other files into Rust doc comments.

Other new features in Rust 1.54:

  • A number of instrinsics for wasm32 platform have been stabilized. These give access to SIMD instructions in WebAssembly.
  • Incremental compilation is re-enabled by default. It had been disabled by default in Rust 1.52.1. With Rust 1.52, additional validation was added when loading incremental compilation from on-disk cache, resulting in pre-existing potential soundness issues being uncovered as validation changed these silent bugs into internal compiler errors (ICE). Since then, work has been done to resolve these issues, with some fixes landing in Rust 1.53 and the majority landing in Rust 1.54. Remaining issues that could result in ICE are considered rare in practice.
  • Multiple methods and trait implementations have been stabilized.
  • Compiler output has been improved for debugging enums on Windows MSVC platforms for C++.

Rust 1.54 follows the June 17 release of Rust 1.53, which contained language and library features including the IntoIterator implementation for arrays.

The new features in Rust 1.52

Introduced May 6, 2021, Rust 1.52 was led by an enhancement to tooling support for Clippy, which is a collection of lints to find mistakes and improve Rust code. Previously, running cargo check followed by cargo clippy would not actually run Clippy, with the build caching in Cargo not differentiating between the two. This has been fixed in Rust 1.52. Also in version 1.52, the following methods were stabilized:

Several previously stable APIs, including char::len_utf8 and u8LLeq_ignore_ascii_case, are now const. For the compiler, the default LLVM has been upgraded to LLVM 12. A subsequent point release of the language, Rust 1.52.1, published May 10, provides a workaround for a bug in incremental compilation that was made into a compiler error in Rust 1.52.0. Rust builders recommend either an upgrade to 1.52.1 or disabling incremental compilation.

The new features in Rust 1.51.0

Published March 25, 2021, the Rust 1.51.0 release is one of the largest additions to the language and Cargo package manager in quite some time, with the stabilization of an MVP (minimum viable product) implementation of const generics and a new feature resolver for Cargo among the highlights. Other highlights:

  • With the const generics MVP, a tool is added for library designers in developing compile-time safe APIs. A highly anticipated feature, const generics are generic arguments that range over constant values, rather than types or lifetimes. This allows types to be parameterized by integers, for example. The plan is to introduce const generics gradually, so the only types that can be used as the type of a const generic argument currently are the types of integers, including size, usize, char, and bool.
  • Along with const generics, a new API has been stabilized that uses it, std::array::IntoIter, which allows developers to create a by value iterator over any array.
  • For Cargo, the new feature resolver introduces an algorithm for computing package features to help avoid some unwanted unification with the current resolver.
  • Improved compile times on MacOS, with improvements to speed up builds that include debug info and reduce the amount of disk space used.
  • Items such as functions, traits, and structs can be parameterized by constant values in addition to types and lifetimes.
  • Stabilized APIs, including stabilization of 18 new methods for types such as slice and Peekable.

The new features in Rust 1.50.0

Published February 11, 2021, Rust 1.50.0 improves array indexing, expands safe access to union fields, and adds to the standard library. Specific improvements include:

  • For const-generic array indexing, this release continues a progression toward stable const generics, adding implementations of ops::Index and IndexMut for arrays [T; N] for any length of Const N. The indexing operator [ ] already worked on arrays through the compiler, but at the type level, arrays did not actually implement the library traits until now. Also, stable use of const values in array repetition is formally acknowledged.
  • Safe assignments to ManuallyDrop<T> union fields are permitted.
  • A niche for File on Unix platforms is now permitted. With this feature, some types in Rust have limitations on what is considered a valid value, which may not cover the range of possible memory values. Any remaining valid value is called a niche, with this space usable for type layout optimizations. On Unix platforms, Rust’s File is made of the system’s file integer descriptor; this happens to have a possible niche because it cannot be -1! System calls that return a file descriptor use -1 to indicate an error occurred, so it is never possible for -1 to be a real file descriptor. Beginning with Rust 1.50, this is added to the type definition so it can be used in layout optimizations, too. It follows that Option<File> now will have the same size as File.
  • For Cargo, a [rustc-workspace-wrapper] option has been added, to set a wrapper to execute instead of rustc, for workspace members only. Also, the --workspace flag has been added to the cargo update command.
  • Nine new stable functions were added to the library: bool::then, btree_map::Entry::or_insert_with_key, f32::clamp, f64::clamphash_map::Entry::or_insert_with_key, Ord::clamp, RefCell::take, slice::fill, and UnsafeCell::get_mut.
  • Also in the library, several existing functions were made const: IpAddr::is_ipv4, IpAddr::is_ipv6, Layout::size, Layout::align, Layout::from_size_align, pow for all integer types, checked_pow for all integer types, saturating_pow for all integer types, wrapping_pow for all integer types, next_power_of_two for all unsigned integer types, and checked_power_of_two for all unsigned integer types.

The new features in Rust 1.49.0

Announced December 31, 2020, Rust 1.49.0 designates 64-bit Arm Linux as a Tier 1 target, thus providing the highest support guarantee, with the full test suite run on this platform on every change merged in the compiler. This support is expected to benefit workloads spanning from embedded systems to servers and desktops. Prebuilt binaries also are available. This marks the first time a non-x86 target has reached Tier 1 support. The Rust development team hopes to bring more platforms into this tier in the future.

Also with Rust 1.49.0, 64-bit Arm for MacOS and Windows reach Tier 2 support. Developers can expect these two targets to have prebuilt binaries installable from rustup. Tier 2 targets are guaranteed to build, and prebuilt binaries are provided. However, the Rust team does not execute the test suite on those platforms. Produced binaries may not work and might have bugs.

Other additions, improvements, and changes in Rust 1.49.0:

  • Three stable functions have been added to the library: slice::select_nth_unstable, slice::select_nth_unstable_by, and slice::select_nth_unstable_by_key.
  • Two library functions were made const: Poll::is_ready and Poll::is_pending.
  • For the language, unions now can implement Drop and developers now can have a field in a union with ManuallyDrop<T>. Also, uninhibited enums can be cast to integers.
  • Developers can bind by reference and bind by move in patterns, enabling developers to selectively borrow individual components of a type.
  • For the compiler, the minimum supported version of LLVM has been moved to LLVM 9.

The new features in Rust 1.48.0

Unveiled on November 19, 2020, Rust 1.48.0 features easier linking in the Rustdoc library documentation tool, with syntax to let Rustdoc know when developers are trying to link to a type; URLs will be generated. Also in version 1.48.0:

  • Developers can specify #{doc(alias = “<alias>”) ] on items to add search aliases when searching through the Rustdoc UI.
  • The unsafe keyword is now syntactically permitted on modules. While still rejected semantically, this can now be parsed by procedural macros.
  • In the compiler, the -C link-self-contained=<yes|no> compiler flag is stabilized. This tells rustc whether to link its own C runtime and libraries or rely on an external linker to find them. This is supported only on windows-gnu, linux-musl, and wasi platforms.
  • In the library, the [T; N]: TryFrom<Vec<T>> API is now stable. Developers can use it to try to turn a vector into an array of a given length. Also stabilized in this release were five other APIs: slice::as_ptr_range, slice::as_mut_ptr_range, VecDeque::make_contiguous, future::pending, and future::ready.
  • Also in the library, all arrays of any length now implement TryFrom<Vec<T>>.

The new features in Rust 1.47.0

Announced October 8, 2020, Rust 1.47.0 has no new language features but enhances the standard library. Quality of life and toolchain improvements as well as library stabilizations are featured in the release. Release notes have been published for the upgrade.

Specific capabilities in Rust 1.47.0 include:

The new features in 1.46.0

Rust 1.46, announced on August 27, 2020, includes the following capabilities:

  • Several core language features now can be used in const fn, including if, if letmatch, and several others.
  • A #[track_caller] attribute, designed to improve error messages when unwrap and related functions panic, is now stable.
  • In a change to the library, std::mem::forget is now a const fn. Also in the library, two new APIs were stabilized: Option::zip and vec::Drain::as_slice.
  • For the compiler, the citylib target can be used on Apple iOS and tvOS platforms.
  • Recursively indexing into tuples no longer requires parentheses.

The new features in Rust 1.45.0

Announced on July 16, 2020, Rust 1.45 includes the following additions and improvements:

  • A fix is offered to mend some longstanding unsoundness when casting between integers and floats.
  • Stabilization is offered for function-like procedural macros in expressions, patterns, and statements. Expansion of the use of macros assists with use of the Rocket web framework for Rust.
  • Several library APIs have been stabilized, such as Arc::as_ptr, BTreeMap::remove_entry, and Span::resolved_at. The full list of APIs can be found in the Rust Blog.

The new features in Rust 1.43.1

This point release was introduced May 7, 2020, to address two regressions introduced in the 1.43.0 stable release. It also updates the OpenSSL version used by the Cargo package manager. Features include:

  • Rust 1.27 introduced support for detecting x86 CPU features in the standard library, via the is_x86_feature_detected macro. Because of an internal refactoring, Rust 1.43.0 prevented detection of features that cannot be used on stable yet, even though detecting them previously was allowed. Version 1.43.1 fixes this regression.
  • A fix is offered for broken cargo package –list command. Rust 1.43 broke support for listing files included in packages published with Cargo, when executed inside a workspace with path dependencies or unpublished versions.
  • OpenSSL, a Cargo dependency, has been updated to 1.1.1g. OpenSSL had released a security advisory but the Rust team was not able to include the fix in time for Rust 1.43.0. The team has no evidence the vulnerability could compromise Cargo users’ security.

The new features in Rust 1.43.0

Announced April 23, 2020, Rust 1.43.0 was considered a fairly minor release, with no major features introduced. Changes include:

  • Developers can use item fragments to interpolate items into the body of trait, impl, and extern blocks.
  • The type inference around primitives, references, and binary operations was improved.
  • To help integration testing, Cargo will set some new environment variables for tests to find executables.
  • In the Rust library, developers can use associated constants on floats and integers directly without having to import the module. Also, there is a new primitive module that re-exports Rust primitive types, which is useful when writing a macro and developers want to ensure types are not shadowed.
  • Several APIs in the library were stabilized: Once::is_completed, f32::LOG10_2, f32::LOG2_10, f32::LOG10_2, f64::LOG10_2, f64::LOG2_10, and iter::once_with.

The new features in Rust 1.41

Rust 1.41.0, announced January 30, 2020, contains the following new features and improvements:

  • Restrictions are relaxed when implementing traits. Prior to Rust 1.41.0, the orphan rule was unnecessarily strict, obstructing composition. The rule was enforced to prevent breakages when a dependency adds a new trait, impl, with the gist being that a trait impl was only permitted if either the trait or the type being implemented is local to the current crate as opposed to a foreign crate.
  • The cargo install command, for installing binary crates and Rust-based CLI tools, now will update existing installations of the crate if a new release has been published.
  • For lock files, which are used to ensure consistent builds, a new format is introduced to avoid unnecessary merge conflicts when changing dependencies in separate branches. The new format will be used for all new lock files while existing lock files still rely on the previous format.
  • More guarantees are offered when using a Box<T> in FFI (Foreign Function Interface). Box<T>, referred to as a box, provides Rust’s simplest form of heap allocation. If developers have an extern “C” Rust function, called from C, the Rust function now can use Box<T> for some specific T, while using T* in C for the corresponding function. However, developers for now should avoid using Box<T> types for functions that are defined in C but invoked in Rust. In these cases, developers should directly mirror the C types as closely as possible.
  • Additions to the library were made, such as stabilizing the Result::map_or and Result:map_or_else. Also stabilized were the weak_count and strong_count methods. NonZero* numerics now implement From<NonZero*> if it is a smaller integer width.
  • Rust 1.41.0 will be the last version with the current level of compiler support for 32-bit Apple targets.

The new features in Rust 1.40

Rust 1.40, released in December 2019, contained the following improvements and changes:

  • It’s now possible to allow macros to themselves generate macros. This allows for far more sophisticated metaprogramming using Rust than was previously possible, except perhaps by manual code generation. It’s now also possible to use procedural macros to define types, and to use them in extern blocks. And the new todo!() macro can be used in place of the more verbose unimplemented!().
  • A new attribute, #[non_exhaustive], lets you decorate a type to indicate it might have more fields or other changes in the future. This keeps other code from overriding the definition or using it as part of an exhaustive pattern match, which might break unexpectedly later on when the type is changed.
  • Code that would have compiled under the old borrow checker, but generates a warning under the new borrow checker, will now generate hard errors. This is both to encourage cleanup of older Rust code and to allow the old borrow checker code to be phased out entirely.
  • Several new compiler targets have been added, such as Arm’s Thumb-2 Neon (version 7) and MIPS64 platforms that use the musl lightweight standard library.

The new features in Rust 1.38

Rust 1.38, released in September 2019, contains the following new features and improvements:

  • The Cargo package manager will take advantage of pipelined compilation automatically with Rust 1.38. With pipelined compilation, the compiler does not need dependencies fully built when compiling a crate. All that is needed is their metadata, such as the list of types of dependencies. Metadata is produced early in the compilation process. Some tests have shown compilation speed increases of 10 to 20 percent for optimized, clean builds of some crate graphs. 
  • Linting of some incorrect uses of mem::{unitialized, zeroed}. With this release, the rustc compiler will provide a lint for a narrow class of incorrect initializations using mem::uninitialized or mem::zeroed.
  • Extension of the #[deprecated] attribute to macros. This attribute has allowed crate authors to notify users that an item of their crate is to be deprecated and removed in a future release.
  • Developers can use std::any::type_name to get the name of a type.
  • Stabilization of a number of functions including <*const T>::cast and <*mutT>::cast.

The new features in Rust 1.37

Rust 1.37, released in August 2019, has the following new features and improvements:

  • An ability to refer to enum variants through type. Developers also can refer to enum variants with Self::Variant.
  • The cargo vendor command, previously a separate crate, is now built in to the language. The command fetches project dependencies, unpacks them into the vendordirectory, and displays the configuration snippet needed to use the vendored code during builds.
  • The rustc compiler supports profile-guided optimization, an optimizing technique for ahead-of-time compilers, via -C profile-generate and -C profile-use.
  • Developers can create unnamed const items.

The new features in Rust 1.36

Version 1.36 of the Rust systems programming language was released in July 2019. Rust 1.36 includes the following new features and enhancements:

  • The Future trait, used for declaring asynchronous work, is now stable. Asynchronous operations in Rust have been coming together in bits and pieces for several versions now, with async and await being the last important remaining pieces.
  • The alloc crate, used for managing memory, is now stable. This crate collects all of the pieces of Rust’s standard library that depend on a global memory allocation mechanism, such as Vec<T>. This way, crates that don’t use the standard library can still make use of the allocator by importing alloc separately—useful for environments where you want code sizes to be as lean as possible.
  • A new type, MaybeUninit<T>, allows you to define objects that may consist of uninitialized memory, such as a lazily allocated array. Rust’s previous mechanism for doing this was a function, mem::uninitialized, that posed many hazards in casual use. MaybeUninit<T> provides a safer way to do this that uses the constraints of Rust’s type system.
  • Non-lexical lifetimes, a feature for recent editions of Rust, has been backported to earlier editions. Non-lexical lifetimes make Rust’s borrow-checking mechanism less difficult to work with (in essence, letting you write a broader range of programs that are still valid Rust), and better able to catch problems that the borrow checker missed.

Other improvements:

  • A new implementation for the HashMap<K, V> type that runs faster and uses less memory.
  • Cargo can now run entirely offline if needed.

The new features in Rust 1.35

Version 1.35, released in May 2019, offers the following:

  • Implementation of the FnOnce, FnMut, and Fn closure traits for Box<dyn FnOnce>, Box<dyn FnMut>, and Box<dyn Fn>.
  • The dbg! macro introduced in Rust 1.32 now can be called without arguments.
  • Fn* closure traits now are implemented for Box<dyn Fn*>.
  • Stabilizations of the standard library.
  • Clippy, providing a collection of lints to catch common mistakes, added a lint, drop_bounds, which is triggered when adding a bound T: Drop to a generic function.
  • A ptr::hash function has been introduced, so developers can avoid hashing the pointed-to value of a reference and instead hash the address.
  • The value of a RefCell can be replaced through a closure. Developers can more ergonomically map and replace the current value of the cell and retrieve the old value.
  • Developers now can easily check whether a value exists in a range.
  • A number of changes have been made to the Cargo, such as the addition of a rustc-cdylib-link-arg key for build scripts to specify linker arguments for cdylib crates.

The new features in Rust 1.34

Released April 2019, Rust 1.34 includes the following new and changed features:

  • Cargo, the project and package management system for Rus, now works with registries other than the default (Crates.io), including self-hosted registries. Note that any Crates hosted on Crates.io can only depend on Crates also in Crates.io.
  • The ? operator, used for unpacking errors and valid values from Result types, can now be used in documentation tests. This makes it possible to write more fully fleshed out test examples alongside the code being documented.
  • Custom attributes can now accept arbitrary token streams. This allows custom attributes in procedural macros to be more succinct and use more idiomatic Rust code.
  • The TryFrom and TryInto traits can now allow type conversions that might allow failure.
  • Many library and API stabilizations have been added, such as support for a wider range of atomic integer types (which can be shared safely between threads).

The new features in Rust 1.33

Rust 1.33 debuted in late February 2019 with the following new features:

  • A new language concept, called pinning, is now available. Pinning allows the developer to specify an object in memory that is guaranteed not to move. The Pin type and the Unpin marker trait are used to implement this.
  • The const fn declaration, used to declare functions that can be called in constant expressions at compile time, has been expanded to cover many more use cases, such as let bindings (including mutable ones), assignment expressions, and expression statements. In short, the const fn declaration makes more of the language available in a compile-time context.
  • The use n as _ syntax allows you to import the impl of a trait without polluting the namespace it is imported into.
  • Many library elements have been stabilized by being made const.

The new features in Rust 1.32

The 1.32 version of Rust, released in January 2019, includes the following changes:

  • The dbg macro. Inserting dbg!() into a Rust application prints any println!-formattable expression to stderr, with a minimal amount of boilerplate. Inserting print statements as an aid to debugging is an old-school technique, but a reliable fallback when you just need to know the state of a variable at a given point in time.
  • The jemalloc memory allocator is no longer the default. Rust applications now use the system’s own memory allocator as the default, with jemalloc available via the jemallocator crate. Using the system allocator reduces the size of Rust binaries by about 300 KB, and makes the default behavior for Rust apps across platforms more consistent. (Rust apps built on Microsoft Windows have used the system allocator by default for some time now.)
  • Macros now have the ability to perform matching against all types of literals—strings, numerics, and char literals. This makes it easier to write macros that accept literals as parameters.
  • More refinements to the way module imports work, further reducing the amount of boilerplate needed for trivial apps.

The new features in Rust 1.31

Rust 1.31, released December 2018, marks the debut of “Rust 2018,” a new edition of the language with changes to syntax and concepts that are potentially backward incompatible.

By default, code compiled with Rust 1.31 uses the earlier Rust syntax rules, i.e. the “Rust 2015” rules. Code must be explicitly tagged with edition = ‘2018’ to use the new Rust 2018 rules.

New features in Rust 1.31 that are available only in Rust 2018 include:

  • Non-lexical lifetimes. In Rust, the compiler has strict rules for how values and variables can be defined and passed around (the “lifetimes” of variables), the better to prevent memory leaks or race conditions. With Rust 1.31, the accuracy of the compiler’s checks for those conditions have been improved. Previously, some code was rejected by the compiler even though it was technically valid and would not cause problems at runtime.
  • Module system changes. Modules, i.e. Rust’s system for managing code imports, have some counterintuitive and arcane rules. Some of these rules have been relaxed and simplified in Rust 1.31 to make it easier for newcomers to become proficient with more of the module system in a shorter time.
  • New and improved developer tools. Rust’s code linter, clippy, is now considered stable enough for production use. The same goes for rustfmt, which formats Rust code according to the official style guide.

New features in Rust 1.31 that are available to all editions of Rust include:

  • const fn. Use this feature to define a function that can be used in a constant context, and allow it to be evaluated at compile time and not run time. A const fn function has to be deterministic; i.e., it has to yield a constant of some kind.
  • Simpler lifetime syntax. The syntax rules for describing a variable’s lifetime require less boilerplate code in some common circumstances.

Some Rust 2018 features, like non-lexical lifetimes, will eventually be backported to Rust 2015 and made available to Rust users without their having to explicitly opt in.

The new features in Rust 1.30

Version 1.30 of Rust, released on October 25, 2018, adds a few new features:

  • Procedural macros allow you to generate custom attributes and functions by way of macros. Rust 1.30 also makes it easier to apply macros to code by way of the use keyword, so that code that uses macros doesn’t have to be cluttered with as many annotations.
  • A number of improvements to the module system are being rolled out starting with this release, many also involving the use keyword. The upshot is that many module system behaviors will be less cumbersome to apply correctly, allow for clearer code, and make it easier to move use statements around in a codebase without having them break spontaneously.
  • Rust has long made it possible to write libraries that have no dependencies on the standard library. It’s now also possible to build applications that have no standard library dependencies, and thus no dependencies on any specific platform. Work on this has been in progress since Rust 1.6.

The new features in Rust 1.29

Version 1.29 of Rust, released September 13, 2018, provides a small but useful number of new features:

  • Cargo has a new subcommand, cargo fix, that automatically applies suggestions auto-generated by the compiler to the code.
  • Another new subcommand, cargo clippy, provides many more warnings about code supplied to the compiler.

The new features in Rust 1.28

Released in early August 2018, Rust 1.28’s most notable features include:

  • Global allocators. Global allocators allow a developer to define the memory allocation system used by a Rust program. Custom memory allocation strategies come in handy on embedded platforms, or in situations where the developer needs tighter-than-usual control over memory layout strategies.
  • Better error message formatting. Rust’s compiler has traditionally provided verbose and explicit error messages, along with suggestions for how to fix the problem. Rust 1.28 introduces more detailed notes about why some error conditions arise, such as invalid string formatting.
  • NonZero types are now a stable addition to the language. This provides a way to ensure that data types, such as integers, use at least one byte, making it easier to anticipate memory allocations and optimize program data placement.
  • Rust’s cargo utility no longer lets you publish crates with build scripts that modify the src directory for an application. This prevents a whole class of bugs from creeping in during the compilation process.

The new features in Rust 1.27

Rust 1.27, released in June 2018, features basic SIMD (single-instruction, multiple-data) capabilities. The std::arch module serves as a gateway to architecture-specific instructions usually related to SIMD. A higher-level std::simd module is planned for the future.

Other new features in Rust 1.27 include:

  • The dyn Trait syntax is stabilized, providing a syntax for trait objects using a contextual dyn. A “bare trait” syntax for trait objects is deprecated, because it is often ambiguous and confusing.
  • The #[must use] attribute can now be used on functions. Previously, it only applied to types, such as Result<T, E>. Parts of the standard library also have been enhanced to use #[must use].
  • Multiple new APIs were stabilized in the release, including DoubleEndedIterator: : rfind and NonNull: :cast.
  • The Cargo package manager for Rust has been upgraded to require a —target-dir flag to change the target directory for a given invocation. Additionally, auto keys have been added to toml, for dealing with targets.

The new features in Rust 1.26

Released in mid-May 2018, highlights of Rust 1.26 include:

  • A reduction in compile times, via a fix impacting nested types.
  • Support for 128-bit integers, twice the size of u64 and holding more values.
  • Library stabilizations, specifically fs::read_to_string, providing a convenience over File::open and io::Read::read_to_string for reading a file into memory.
  • The Cargo package manager is expected to offer faster resolution of lock files and require manual cargo update invocations less often. 
  • The impl Trait feature, allowing for abstract types in returns or function parameters, is now stable. Existential types are provided.
  • Better match bindings, with the compiler automatically referencing or dereferencing in match.
  • Basic slice patterns, which allow you to match on slices in a similar way to matching on other data types.

The new features in Rust 1.25

Rust 1.25, released in March 2018, features an upgrade to its LLVM (Low-Level Virtual Machine) compiler infrastructure that improves support for the WebAssembly portable code format, which itself is designed to improve the performance of web applications. Rust 1.25 also includes improvements to the Cargo package manager and library stabilizations.

New Rust features from the LLVM upgrade

The Rust language has been upgraded to LLVM 6 from LLVM 4. This lets Rust keep abreast of the upstream WebAssembly back end and pick up new features when they land.

The LLVM upgrade also fixes some SIMD-related compilation errors. For internet of thigs (IoT) development, LLVM 6 brings Rust closer to supporting the AVR microntroller family, leveraged in the Arduino Uno board. Rust, Mozilla claims, can improve security and reliability of IoT devices and is much better at this than the C/C++ languages commonly used to write microcontroller firmware. AVR support is due soon.

New Rust features from the Cargo CLI changes

For the Cargo command-line interface, cargo new will default to generating a binary rather than a library. Rust’s developers said they try to keep the CLI stable but that this change was important and unlikely to result in breakage. They said that cargo new accepts two flags:

  • —lib, for building libraries
  • —bin, to build binaries or executables

In previous versions of Cargo, developers who did not pass one of these flags would default to —lib. This was done because each binary often depends on other libraries, thus making the library case more common. But this behavior is actually incorrect, because each library is depended on by many binaries. Also, some community members found the default surprising.

Other new features in Rust 1.25

Other features in Rust 1.25 include:

  • Library stabilizations include a std::ptr::NonNull<T> type, which is nonnull and covariant.
  • libcore has gained the time module, with the Duration type that had only been available in libstd
  • Checkouts of Git dependenices from the Cargo database folder should be quicker, due to the use of hard links. Cargo caches Git repositories in a few locations.
  • Nested imports groups provide a new way to write use statements, which can reduce repetition and foster clarity.