4

I've been messing around with nightly rustfmt and all its options (so many more than the stable version).

So, just out of curiosity: if I want to use rustfmt only to format my imports (the use statements), without touching the rest of the code, is it possible?

rodrigocfd
  • 6,450
  • 6
  • 34
  • 68
  • I don't have a way to test that right now, but perhaps you can set `disable_all_formatting = true` then individually enable the settings you want. – Chayim Friedman Dec 24 '21 at 02:08
  • 3
    @ChayimFriedman I just tried with `disable_all_formatting = true` and `reorder_imports = true` but it dutifully does not format anything, not even the imports :/ – kmdreko Dec 24 '21 at 02:12
  • If you tag an item with `#[cfg_attr(rustfmt, rustfmt_skip)]`, then it won't be formatted. Unfortunately I think you'd have to do this for *every* item that's not an import, which would be too onerous. More info: https://github.com/rust-lang/rustfmt/issues/1322 – BallpointBen Dec 24 '21 at 05:35

1 Answers1

2

I think it is impossible since many configurations don't have a disable option.

You can find all configurations here

Campbell He
  • 297
  • 2
  • 9