Support use of rustfmt-nightly
See original GitHub issueThis plugin exposes the action Reformat file with rustfmt
. As far as I can tell, this works by running cargo fmt -- --write-mode=overwrite --skip-children
.
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.
[…]
Longer term, we are moving to distribute Rustfmt with the main Rust distro, so all users will be able to use libsyntax-based rustfmt.
If you have both stable and nightly compilers installed, you can install rustfmt-nightly
with cargo +nightly install rustfmt-nightly
and run it with cargo +nightly fmt
, whether you are on stable or nightly at the time.
This plugin should allow the rustfmt
action to use rustfmt-nightly
as the previous crate will no longer be receiving updates.
Likely, this will need to be rolled into better UI-based support of using rustfmt
as an external code formatter. The very minimum to avoid strange errors and questions is probably to catch cargo exit code -1073741515
and display a popup that cargo failed, likely because of running a nightly-compiled cargo on stable. Alternatively, just add the +nightly
flag to the cargo call, which should (untested) cause cargo to complain “you don’t have nightly installed” if nightly is not installed. I don’t think there is a solution that works on stable with current rustfmt and on stable forcing nightly with rustfmt-nightly.
Oh, and if anyone wants to set up an IDEA run configuration to run rustfmt-nightly
, I got it working with Command: +nightly
and Additional arguments: fmt -- --write-mode=overwrite --skip-children
. Unfortunately, if you put fmt
as the command and +nightly
into the additional arguments, cargo receives cargo fmt +nightly -- ...
which fails in some manner I don’t quite understand.
EDIT: there’s a box to select the build channel right next to command. Set that to nightly and have your command as fmt.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:8 (2 by maintainers)
Top GitHub Comments
Looks like that it’s outdated due to
rustfmt-preview
Yes, but this needs to be clearer. Like for example add this to one of the first chapters in the book and stress the idea of proper uniform formatting, which can also help new comers learn/read/understand code easier, due to more recognizable patterns in formatting, code expression, etc.