Ask rustfmt to make our imports consistent

These are nightly-only options: so keep them in a separate file.

When it sees unstable features, stable rustfmt gives a diagnostic like:

> Warning: can't set `imports_granularity = Module`, unstable features are only available in nightly channel.
> Warning: can't set `group_imports = StdExternalCrate`, unstable features are only available in nightly channel.

But: _does_ otherwise format the files and exit non-zero.  However, this is noisy.

We arrange that `cargo +nightly fmt-unstable` also does the right thing.
This commit is contained in:
Joseph Birr-Pixton 2023-11-08 14:07:29 +00:00 committed by Joe Birr-Pixton
parent bce2e5e241
commit b6f283ed79
2 changed files with 9 additions and 0 deletions

3
.cargo/config.toml Normal file
View File

@ -0,0 +1,3 @@
[alias]
fmt-unstable = ["fmt", "--", "--config-path", ".rustfmt.unstable.toml"]

6
.rustfmt.unstable.toml Normal file
View File

@ -0,0 +1,6 @@
# keep in sync with .rustfmt.toml
chain_width = 40
# format imports
group_imports = "StdExternalCrate"
imports_granularity = "Module"