Home Rust Rust 1.81.0 Released: Here’s What’s New And How To Update It

Rust 1.81.0 Released: Here’s What’s New And How To Update It

By sk
274 views

The Rust team has released Rust 1.81.0, introducing a range of improvements to the language's stability, performance, and developer experience.

Rust 1.81.0 ships with several new features and improvements, including the stabilisation of the Error trait in core, making it available for use in #![no_std] libraries.

The standard library's sorting algorithms have been updated to improve performance, and a new lint level, expect, has been added to allow developers to explicitly note where a particular lint should occur.

In addition, several APIs have been stabilised, including char::from_u32_uncheckedCStr::count_bytes, and CStr::from_ptr.

This version also includes a number of compatibility notes, including changes to the panic hook and panic handler arguments, the default behaviour of uncaught panics in extern "C" functions, and the WASI 0.1 target naming.

Finally, the update includes a fix for CVE-2024-43402, which affected how std::process::Command handles arguments when invoking batch files on Windows.

Let us discuss these new features in detail.

What's New in Rust 1.81.0

This new version brings several key enhancements, including:

1. Stabilization of core::error::Error:

Rust 1.81.0 stabilizes the Error trait within the core library, making it usable in #![no_std] libraries. This allows for broader standardization on the same Error trait across the Rust ecosystem, irrespective of the target environment.

2. New Sort Implementations:

Both the stable and unstable sort implementations in the standard library benefit from updated algorithms, leading to improved runtime performance and compilation times.

The updated algorithms also actively detect and panic on incorrect implementations of Ord, preventing unexpected behaviour and encouraging developers to maintain correct ordering implementations.

3. Introduction of #[expect(lint)]:

This new lint level enables developers to explicitly note when a particular lint should occur, issuing a warning if it doesn't.

This is useful for temporarily silencing a lint due to ongoing refactoring or lint implementation bugs, while still maintaining awareness of when the lint needs to be addressed.

For instance, when migrating a codebase to comply with a new restriction enforced by a Clippy lint, developers can use #[expect(lint)] to track progress and ensure that the lint can be enforced once the codebase is compliant.

4. Lint Reasons:

Developers can now provide reasons when changing lint levels. These reasons are included in compiler messages, providing context and clarity to other developers who might encounter the lint in the future.

For example, if a project disables floating-point arithmetic using #![deny(clippy::float_arithmetic)] due to running in an environment without floating-point support, a reason can be added to explain this decision directly within the code.

5. Stabilized APIs and Const Context Expansion:

Rust 1.81.0 stabilizes several APIs, including core::error, hint::assert_unchecked, and fs::exists. Additionally, more APIs, such as char::from_u32_unchecked and CStr::from_ptr, are now stable within const contexts, expanding the functionality available in const contexts.

6. Improved Safety and Compatibility:

Rust 1.81.0 brings a series of changes to enhance safety and compatibility. These include splitting panic hook and panic handler arguments, aborting on uncaught panics in extern "C" functions (encouraging the use of -unwind suffixed ABI variants for unwinding across ABI boundaries), and renaming the WASI 0.1 target from wasm32-wasi to wasm32-wasip1 (with plans to remove wasm32-wasi in January 2025).

Beyond these major changes, Rust 1.81.0 includes a fix for CVE-2024-43402, ensuring correct argument escaping when invoking batch files on Windows using std::process::Command.

This release also includes a variety of other enhancements and bug fixes across Rust, Cargo, and Clippy.

Upgrade to Rust 1.81.0 in Linux

To update to Rust version 1.81.0, you can use the rustup tool. If you installed a previous version of Rust using rustup, you can upgrade to 1.81.0 by running the following command in your terminal in Linux:

$ rustup update stable

If you don't already have rustup installed, you can download it from the official Rust website and install it as shown in the following link:

Resource:

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More