mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 20:31:19 -03:00
build_tools/style.fish: check that {rustfmt,Cargo}.toml edition specs are in sync
Commit1fe6b28877(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 by00784248db(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
This commit is contained in:
3
.github/workflows/lint.yml
vendored
3
.github/workflows/lint.yml
vendored
@@ -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
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
edition = "2024"
|
||||
style_edition = "2024"
|
||||
|
||||
@@ -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 <Cargo.toml)" = "$($edition_spec <.rustfmt.toml)"
|
||||
or die "Cargo.toml and .rustfmt.toml use different editions"
|
||||
|
||||
echo === Running "$green"rustfmt"$normal"
|
||||
if set -l -q _flag_check
|
||||
if test $all = yes
|
||||
|
||||
Reference in New Issue
Block a user