rustfmt: Rustfmt doesn't respond to imperfect commands?
This, and many other attempts at using rustfmt on the command line does not seem to work for me?
(c) Microsoft Corporation. All rights reserved.
C:\Users\mikke>rustfmt -v
cls
^C
C:\Users\mikke>
(the cls and ^C is done by me because it wasn’t responding)
I really tried looking for what I’m doing wrong, but I don’t seem to able to find any help on this. I was just trying to make a global rustfmt config file (“{user}.config\rustfmt\rustfmt.toml”), and using that for my cargo projects. For this I also tried using rust-analyzer’s “extra arguments” setting in VSCode, but that didn’t seem to have any effect either in the multiple ways I tried to use it.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 18 (8 by maintainers)
Glad that we were able to help you resolve your issues! Don’t hesitate to reach out if anything else comes up.
check out the configuration docs for how to set a global config directory.
The default edition is
2015, and when you runcargo fmtthe edition will be read from yourcargo.tomlif not otherwise specified. You can also seteditionin your rustfmt.tomlNow I just need to make this work using rust-analyzer/VSCode save-autoformatting?Wait it worked now! I guess the issue was probably that I was only really trying use unstable features? Oh well.Oh yeah, I think it’s
Ctrl+Zon windowsAh.
Ctrl+Ddidn’t do it, butCtrl+Zdid!@mikkelens normally you’d pass a file path to rustfmt e.g
rustfmt path/to/file.rs. However, when you don’t pass a file rustfmt is expecting input to come from stdin, and is waiting for your to give it some input.For example.
rustfmt -vCtrl+Don your keyboard to flush stdin, and rustfmt will format thefn main ( ) {}