Rustfmt releases


There are some significant changes happening to Rustfmt. Here is what you need to know.

We’re changing the default style to match that being specified in the style RFC process. Earlier this week I made the last release using the old default style (0.8.6). Today I released 0.9 which uses the new style. There will be no more development on the 0.8 branch. If you want to continue using the old style, you can use rustfmt.toml to configure rustfmt, the options you need to set are in legacy-rustfmt.toml.

There are likely to be a few more bugs than usual as the dust settles on the new style. Please file issues if you encounter them. Apologies in advance and bare with us.

We’re also changing the parsing library used in Rustfmt from Syntex to libsyntax (because Syntex is not going to be maintained). This won’t affect formatting or much else for end users, however, it means rustfmt will only work with the nightly toolchain. So as not to cause too much disruption, we won’t make this change to the rustfmt crate, but are adding a new one - rustfmt-nightly. If you can, we recommend you use that. New development will only happen on that crate (I will try to backport some PRs for a while). Even if you use the stable toolchain, Rustup makes it easy to switch between nightly and stable toolchains.

rustfmt-nightly is using the RFC style by default.

Longer term, we are moving to distribute Rustfmt with the main Rust distro, so all users will be able to use libsyntax-based rustfmt.

I blogged a little bit about these changes a couple of weeks ago, for a few more details:


Awesome, love the new RFC style. No more whacky 1 and 3 space indents :slight_smile:


@nrc Can the installation instructions on the repo be updated? It would be great to also see something about upgrading to this version because I’m not sure what if anything that would require. :slight_smile:


@nrc For example, I just ran rustup run nightly cargo install rustfmt-nightly because that seems like the correct thing to do. Then I tried running rustfmt --version to see if the installation worked. This resulted in the following error:

rustfmt: error while loading shared libraries: cannot open shared object file: No such file or directory

I tried googling around but I’m really not sure how to solve this.


You’ll have to run rustfmt in the nightly environment rustup run nightly rustfmt ...


Thank you! I just also figured that out.

rustup run nightly rustfmt

This works!

Thanks for your help!

Edit: For those who might be new to this, you now need to run cargo +nightly fmt if you want to run cargo fmt and your default toolchain is stable.


yep, I’ll add some instructions, thanks for the idea!


I’ve just installed rustfmt-nightly and run it on a few of my crates, and looks fantastic. The new style absolutely gels with the way my brain seems to work with code, it’s immediately more readable.

Thanks for the fantastic work @nrc and other contributors, I feel rustfmt is quickly becoming indispensable just as go fmt became for Go.


Are the style decisions summarised anywhere? The github issues are often very long and the style guide appears to cover much less than the issues.


Not yet, we are in the process of making the style guide more complete, but it is has been pretty slow. If you’d like to help out, we’d love help with this.


Ok, thanks for the response. I installed rustfmt 0.9 and was surprised by the formatting of function arguments. From this guide it looks like what I’m seeing matches the “block” option for fn_args_layout, but the page claims that the default is “visual”. Is it enough to just update the defaults listed on that page or is it also out of date in other ways?


Ah, yes, I forgot to update, sorry. I filed to track. I think only the defaults are out of date.

The default for that is ‘Block’ now.


Great, thanks!


Just wanted to express how much nicer this new style is. I’ve never been a fan of alignment, and it’s especially problematic in Rust, since code tends to be pretty long, and heavily nested, so eventually there isn’t enough space. The alignment stye of rustfmt always felt cramped and dense, whereas the new style feels airy and readable to me. Since Rust is a very dense and symbol heavy language to begin with, I feel that anything that helps us fight noise is great, and these changes are a great step in that direction. I’m very excited.


How do I run this? doesn’t say how. The Documentation link doesn’t say either. It’s unclear whether github page is for the new or the old version.


The GitHub page is for the old version, which is why I asked above for @nrc to update the instructions.

Here’s a quick guide to get you started:

You either need to have the nightly toolchain (nightly Rust) or have rustup installed.

  • If you have Rust nightly, run cargo install rustfmt-nightly
  • If you have rustup, run rustup run nightly cargo install rustfmt-nightly

Either way, rustfmt-nightly will be installed using nightly Rust. You may have to install the nightly toolchain using rustup instal nightly if rustup complains about nightly not being present. I’m not sure if it installs missing toolchains automatically.

Once you have it installed, you need to run rustfmt or cargo fmt if you want to format your entire project.

  • If you have Rust nightly,
    • rustfmt <files> will format specific files for you
    • cargo fmt will format your entire project
  • If you have rustup,
    • rustup run nightly rustfmt <files> will format specific files for you
    • rustup run nightly cargo fmt will format your entire project

There are more options for both cargo fmt and rustfmt, but this should help you get started! :smile:


I’ve updated the with instructions for running the nightly version of Rustfmt.


I have a question in regards to running the ensuing rustfmt as I’ve only ever casually touched stable:

Once built with the nightly toolchain (and assuming you remain on the nightly toolchain) is there any way to invoke rustfmt with out the use of rustup run nightly rustfmt (or equivalent) or by switching to the nightly shell via rustup run nightly bash? If I attempt to do so I’ll get the missing shared library error.

I couldn’t find an answer and this may just be the way it works. Thanks,


That’s something @nrc could answer better than I can. I think the problem is that rustfmt is dynamically linking against the nightly compiler so you either need to set your default toolchain to nightly or use rustup.

This is also the same as what it says in the README.


You could try export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib:$LD_LIBRARY_PATH.