Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon

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

Save for later
  • 3 min read
  • 27 Sep 2019

article-image

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 a 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.

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at €18.99/month. Cancel anytime

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.

https://twitter.com/gilescope/status/1177229413320134661

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

https://twitter.com/shirshak55/status/1177247635285000192

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

Introducing Weld, a 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