diff --git a/rustfmt.toml b/rustfmt.toml index 44cbfe4a3dc9..f8ff0d0fd105 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -6,13 +6,3 @@ edition = "2021" style_edition = "2024" use_small_heuristics = "Max" merge_derives = false - -ignore = [ - "**/build/", - "**/target/", - - # Do not format submodules - # For some reason, this is not working without the directory wildcard. - "**/firecracker", - "**/tests/perf/s2n-quic/", -] diff --git a/scripts/kani-fmt.sh b/scripts/kani-fmt.sh index 5eca1582cc40..6a136f244ff8 100755 --- a/scripts/kani-fmt.sh +++ b/scripts/kani-fmt.sh @@ -19,19 +19,25 @@ error=0 cargo fmt "$@" || error=1 # Check test source files. -# Note that this will respect the ignore section of rustfmt.toml. If you need to -# skip any file / directory, add it there. TESTS=("tests" "docs/src/tutorial") +# Add ignore patterns for code we don't want to format. +IGNORE=("*/perf/s2n-quic/*") + +# Arguments for the find command for excluding the IGNORE paths +IGNORE_ARGS=() +for ignore in "${IGNORE[@]}"; do + IGNORE_ARGS+=(-not -path "$ignore") +done for suite in "${TESTS[@]}"; do # Find uses breakline to split between files. This ensures that we can # handle files with space in their path. set -f; IFS=$'\n' - files=($(find "${suite}" -name "*.rs")) + files=($(find "${suite}" -name "*.rs" ${IGNORE_ARGS[@]})) set +f; unset IFS # Note: We set the configuration file here because some submodules have # their own configuration file. - rustfmt --unstable-features "$@" --config-path rustfmt.toml "${files[@]}" || error=1 + rustfmt --config-path rustfmt.toml "${files[@]}" || error=1 done exit $error