News

Rust 1.38 releases with pipelined compilation for better parallelism while building a multi-crate project

3 min read

After releasing Rust 1.37 last month, the Rust team announced the release of Rust 1.38 yesterday. This version supports pipelined rustc compilation, an extended #[deprecated] attribute for macros, the std::any::type_name function to know the type name, and more.

Key updates in Rust 1.38

Pipelined compilation to increase parallelism

Rust’s dependency manager and project compiler, Cargo create a directed acyclic graph  (DAG) of crates whenever a cargo build command is fired. Cargo waits till all of the dependencies for that compilation is completed, only then it proceeds to execute rustc.  Starting with 1.38, this wait is minimized by introducing pipelined compilation. Cargo will now take advantage of the metadata produced by the compiler to start the next compilation.

Read also: Rust 1.29 is out with improvements to its package manager, Cargo

The team shared in the announcement that though this update doesn’t have much effect on builds for single crate, it has shown up to 10-20% improvement in compilation speed during testing. “Other ones did not improve much, and the speedup depends on the hardware running the build, so your mileage might vary. No code changes are needed to benefit from this,” the team adds.

Linting incorrect uses of mem::{uninitialized, zeroed}

Previously, the ‘mem::uninitialized’ function allowed developers to sidestep Rust’s initialization checks. This operation can be “incredibly dangerous” as it makes the Rust compiler assume that values are properly initialized.

This was addressed in Rust 1.36 by stabilizing the ‘MaybeUninit<T>’ type. The Rust team explained in a previous announcement, “The Rust compiler will understand that it should not assume that a MaybeUninit<T> is a properly initialized T. Therefore, you can do gradual initialization more safely and eventually use .assume_init() once you are certain that maybe_t: MaybeUninit<T> contains an initialized T.

The ‘mem::uninitialized’ function is planned to deprecate in Rust 1.39. Starting with Rust 1.38, the compiler has a few checks to identify incorrect initializations using ‘mem::uninitialized’ or ‘mem::zeroed’. However, these checks do not cover all cases of unsound use of these methods.

The #[deprecated] attribute for macros

Rust 1.9 introduced the  #[deprecated] attribute that allows crate authors to notify their users an item of their crate is deprecated and will be removed in a future release. In Rust 1.38, this attribute can also be applied to indicate the deprecation of macros.

The std::any::type_name function

Rust 1.38 introduces a new function called ‘std::any::type_name’ that gives you the type name. Since this is a standard library function for debugging, the exact content and format of the string are not guaranteed. The team explains, “The value returned is only a best-effort description of the type; multiple types may share the same type_name value, and the value may change in future compiler releases.

Some users have already upgraded to Rust 1.38 and shared their feedback on Twitter.

While others are eagerly waiting for the release that will have the stabilized async-await.

These were some of the updates in Rust 1.38. Check out the official announcement for more.

Read Next

Introducing Weld, runtime written in Rust and LLVM for cross-library optimizations

Mozilla introduces Neqo, Rust implementation for QUIC, new http protocol

Introducing Nushell: A Rust-based shell

Oracle releases JDK 13 with switch expressions and text blocks preview features, and more!

Darklang available in private beta

Bhagyashree R

Share
Published by
Bhagyashree R

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago