Feeling a little Rusty? v1.49 arrives just in time for new year’s, elbows language onto 64-bit Arm

Rust 1.49

The team behind programming language Rust ended 2020 with the release of v1.49, so that users can start the new year with more stabilised APIs, improved 64-bit Arm support, and a few language enhancements.

The latter are rather small in nature and mainly stabilise or clarify certain behaviours. Unions for instance can now be set up with a field type ManuallyDrop<T> and come with a stabilised “impl Drop for Union” feature. Developers also gained the ability to cast uninhabited enums to integers, and can finally borrow individual components of a type, since patterns now allow binding by reference and move. 

To stop users from stumbling upon weird behaviour when working with RangeInclusive::contains, the Rust team altered its implementation to also check for the exhausted flag. Before, this was only done in the is_empty method and led to unexpected output when a range finished iteration.

Moreover, Rust 1.49 includes Index and IndexMut so that arrays don’t lose indexing functionality when implementing something along the lines of Index<MyIndexType> for an array, and ToString::to_string no longer shrinks the internal buffer by default. The Rust team also fixed some issues with text capturing, so that the integrated testing framework is now able to correctly catch text printed from new threads.


Looking into APIs, slicing methods slice::select_nth_unstable, slice::select_nth_unstable_by, and slice::select_nth_unstable_by_key are now marked as stable and can be used to reorder slice elements with comparator or key extraction functions. Poll::is_ready and Poll::is_pending have been turned into const fn, meaning that they can now be executed in a const context.

Other than that, the Rust team has re-evaluated their support levels for various targets and bumped vaarch64-unknown-linux-gnu onto the highest available tier. This basically means that developers using 64-bit Arm systems with Linux can rest assured a full test-suite has been run for every change merged into the compiler. Teams that are more comfortable with macOS and Windows can meanwhile get prebuilt binaries and a build guarantee, since there’s now tier 2 support for Rust on Apple M1 and Windows on Arm available.

As usual, the Rust language update also includes a new release of Cargo. This time, Rust’s package manager has learned to build independently reproducible crates with cargo-package, and accept glob patterns for package and target specifications. Version 1.49 also includes a new build-time environment variable called CARGO_PRIMARY_PACKAGE for indicating “root packages requested on the command-line”. This is meant to be especially helpful when using the –fix flag, since it can let lint collection clippy know when to not emit lints to reduce problems in that particular scenario.

Speaking of clippy, the collection gained a variety of false positive fixes, and 17 new lints since the last release to help finding issues like loops with just one element, inefficient calls to Mutex::lock, or the integration of less than ideal methods. The lint for identifying drop_bounds has been uplifted into rustc and was therefore deprecated in clippy, while single_char_push_str was renamed to single_char_add_str and zero_width_space is now known as invisible_characters. Developers looking for string_lit_as_bytes or rc_buffer will need to turn to nursery or restriction respectively, as those lints have been moved there.

Before making the switch to Rust 1.49, a brief look into the compatibility notes is advised, since changes in the stripping of whitespaces in comments or treatment of macros ending in semi-colons might lead to slightly different behaviour of old programs.

- Advertisement -