BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Rust 1.12 Brings Mid-Level IR

Rust 1.12 Brings Mid-Level IR

The Rust core team has released the stable version of 1.12, calling it one of the most significant Rust releases since 1.0. The release brings the long-awaited Mid-Level IR (MIR), paving the way for future compiler optimisations.

In the blog post Introducing MIR, Mozilla's Niko Matsakis said:

MIR comes between the existing HIR (“high-level IR”, roughly an abstract syntax tree) and LLVM (the “low-level” IR.) Previously, the “translation” phase in the compiler would convert from full-blown Rust into machine-code-like LLVM in one rather large step. But now, it will do its work in two phases, with a vastly simplified version of Rust – MIR – standing in the middle.

Rust contributor Steve Klabnik says that the simplified translation pass creates opportunities to perform new optimisations directly on the MIR.

While the Rust team claim that MIR doesn't bring anything "user-visible" Matsakis details a faster compilation time, with incremental compiling, along with a faster execution time, and more precise type checking.

The latest stable release brings some significant updates that are user visible, including a new format for rustc error messages, as show below:

The team explains:

[the new error format] helps to surface a lot of the internal knowledge about why an error is occurring to you, the developer. It does this by putting your code front and center, highlighting the parts relevant to the error with annotations describing what went wrong.

In the new error format we represent the error by showing the points in the code that matter the most.

Initially, this error design was built to aid in understanding borrow-checking errors, but we found the format can be broadly applied to a wide variety of errors. If you would like to learn more about the design, check out the previous blog post on the subject.

Mozilla engineer Jonathan Turner described the significance of this change in the blog post Shape of Errors to Come, saying that by using the code the developer wrote as the context, Rust gives an easy way to know at a glance where the issue is occurring.

Also new in the 1.12 release is the workspaces feature for Cargo, allowing a group of Rust packages to share the same Cargo.lock file making it easier for developers to be able to keep shared dependencies on a single version.

Detailed release notes for Rust 1.12 are available on GitHub, and the release can be downloaded from here.

Rate this Article

Adoption
Style

BT