BT

Rust Gets Incremental Compiler and Standard Code Formatter

| by Sergio De Simone Follow 18 Followers on Feb 18, 2018. Estimated reading time: 1 minute |

Rust 1.24 brings two new major features: incremental compilation and a standard code formatter, rustfmt.

The Rust core team started working on incremental compilation at the end of 2015 and had an alpha version ready by September 2016. Since then the team has been working on making it production-ready by fixing crashes and improving its correctness. Now, Rust 1.24 enables incremental compilation by default. If you do not want to use it, you can disable it on a per-project basis, using profile.dev.incremental in Cargo.toml, or globally, using build.incremental in .cargo/config.

Incremental compilation is not the only change that Rust 1.24 includes to improve performance. Indeed, Rust 1.24 has stabilized codegen-units, which makes it possible to run multiple compiler code generation phases in parallel. One drawback of the new codegen-units behavior is that the final binary tends to be a bit slower. To disable the new behavior and ensure maximum runtime performance of your binary, you can set codegen-units to 1 in Cargo.toml.

Rust 1.24 also introduces a preview of rustfmt, a tool for formatting Rust code according to style guidelines. You can install rustfmt-preview by running rustup component add rustfmt-preview and then you can run it on a file with rustfmt filename, which will format all included modules as well.

rustfmt supports a number of output modes that can be set using the --write-mode flag on the command line. You can, for example, overwrite the original files, replace them after creating backups, just display the formatted output, and more. rustfmt can also be integrated with many editors, including Vim, Emacs, Sublime Text 3, Atom, and others.

For the full detail of what is new in Rust 1.24, please consult the release notes.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT