From b4fb870af67201f29ca271bd0edddca714442a54 Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Tue, 16 May 2023 12:35:49 +0200 Subject: [PATCH] Enable `imports_granularity` for `rustfmt` (#637) This requires us to run a nightly Rust for our formatting check[1]. Other users will see a warning when invoking `rustfmt`: Warning: can't set `imports_granularity = Module`, unstable features are only available in nightly channel. This should be harmless overall and help us ensure better consistency in our import formatting. [1]: https://rust-lang.github.io/rustfmt/?version=v1.5.1&search=#imports_granularity --- .github/workflows/build.yml | 7 ++++++- rustfmt.toml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2f3715a8..5e9964a5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,12 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Format Rust code + - name: Install nightly rustfmt + run: | + rustup default nightly + rustup component add rustfmt + + - name: Check Rust formatting run: cargo fmt --all -- --check cargo: diff --git a/rustfmt.toml b/rustfmt.toml index 2b1dd5bb..40b837b3 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +1,2 @@ -# imports_granularity = "module" +imports_granularity = "module" # Please use nightly for this setting. max_width = 90