Skip to content

Commit 9f52753

Browse files
authored
Remove unstable-features from code formatting script (#3962)
The code formatting script [scripts/kani-fmt.sh](https://github.com/model-checking/kani/blob/main/scripts/kani-fmt.sh) currently uses `--unstable-features` to enable the usage of the `--ignore` pattern in [rustfmt.toml](https://github.com/model-checking/kani/blob/main/rustfmt.toml). Since we're already using a find command to find all the files to format, it is easy to instead add the patterns to exclude to the find command rather than relying on an unstable feature. Resolves #ISSUE-NUMBER By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
1 parent 49c4b6f commit 9f52753

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

rustfmt.toml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,3 @@ edition = "2021"
66
style_edition = "2024"
77
use_small_heuristics = "Max"
88
merge_derives = false
9-
10-
ignore = [
11-
"**/build/",
12-
"**/target/",
13-
14-
# Do not format submodules
15-
# For some reason, this is not working without the directory wildcard.
16-
"**/firecracker",
17-
"**/tests/perf/s2n-quic/",
18-
]

scripts/kani-fmt.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,25 @@ error=0
1919
cargo fmt "$@" || error=1
2020

2121
# Check test source files.
22-
# Note that this will respect the ignore section of rustfmt.toml. If you need to
23-
# skip any file / directory, add it there.
2422
TESTS=("tests" "docs/src/tutorial")
23+
# Add ignore patterns for code we don't want to format.
24+
IGNORE=("*/perf/s2n-quic/*")
25+
26+
# Arguments for the find command for excluding the IGNORE paths
27+
IGNORE_ARGS=()
28+
for ignore in "${IGNORE[@]}"; do
29+
IGNORE_ARGS+=(-not -path "$ignore")
30+
done
2531

2632
for suite in "${TESTS[@]}"; do
2733
# Find uses breakline to split between files. This ensures that we can
2834
# handle files with space in their path.
2935
set -f; IFS=$'\n'
30-
files=($(find "${suite}" -name "*.rs"))
36+
files=($(find "${suite}" -name "*.rs" ${IGNORE_ARGS[@]}))
3137
set +f; unset IFS
3238
# Note: We set the configuration file here because some submodules have
3339
# their own configuration file.
34-
rustfmt --unstable-features "$@" --config-path rustfmt.toml "${files[@]}" || error=1
40+
rustfmt --config-path rustfmt.toml "${files[@]}" || error=1
3541
done
3642

3743
exit $error

0 commit comments

Comments
 (0)