InfoQ Homepage News Rust Gets Incremental Compiler and Standard Code Formatter

Rust Gets Incremental Compiler and Standard Code Formatter

Leia em Português


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

We need your feedback

How might we improve InfoQ for you

Thank you for being an InfoQ reader.

Each year, we seek feedback from our readers to help us improve InfoQ. Would you mind spending 2 minutes to share your feedback in our short survey? Your feedback will directly help us continually evolve how we support you.

Take the Survey

Rate this Article


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.

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

Community comments

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

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


Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.