From 54b39be7e793e21b0347f2a8141909cbc37abfb8 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Wed, 22 Oct 2025 18:47:15 +0200 Subject: [PATCH] build_tools/style.fish: check that {rustfmt,Cargo}.toml edition specs are in sync Commit 1fe6b288779 (rustfmt.toml: specify edition to allow 2024 syntax, 2025-10-19) mentions that "cargo fmt" has different behavior than "rustfmt" before that commit. Probably because when .rustfmt.toml exists, rustfmt implicitly uses a different edition (2018?) that doesn't support c"" yet. That commit bumped the edition to 2024, which caused yet another deviation from "cargo fmt": Error writing files: failed to resolve mod `tests`: cannot parse /home/johannes/git/fish-shell/src/wutil/tests.rs error: expected identifier, found reserved keyword `gen` --> /home/johannes/git/fish-shell/src/tests/topic_monitor.rs:48:9 | 48 | for gen in &mut gens_list { | ^^^ expected identifier, found reserved keyword This has since been fixed by 00784248db8 (Update to rust 2024 edition, 2025-10-22). Let's add a test so that such changes won't randomly break "rustfmt" again. Fix that by using 2021 edition, like we do in Cargo.toml. In future, rustfmt should probably default to a current edition (or maybe read the edition from Cargo.toml?) Not yet sure which one is the upstream issue, maybe https://github.com/rust-lang/rustfmt/issues/5650 --- .github/workflows/lint.yml | 3 +++ .rustfmt.toml | 1 - build_tools/style.fish | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8f424e08c..0dd9d5c09 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,6 +19,9 @@ jobs: run: cargo build - name: check format run: PATH="target/debug:$PATH" build_tools/style.fish --all --check + - name: check rustfmt + run: find build.rs crates src -type f -name '*.rs' | xargs rustfmt --check + clippy: runs-on: ubuntu-latest diff --git a/.rustfmt.toml b/.rustfmt.toml index f3e454b61..f216078d9 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,2 +1 @@ edition = "2024" -style_edition = "2024" diff --git a/build_tools/style.fish b/build_tools/style.fish index 0cc612bf5..f26305f20 100755 --- a/build_tools/style.fish +++ b/build_tools/style.fish @@ -101,6 +101,10 @@ if test $all = yes; or set -q rust_files[1] exit 127 end + set -l edition_spec string match -r '^edition\s*=.*' + test "$($edition_spec