diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 85937a8e4445..45c0bea370ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -95,15 +95,9 @@ jobs: # We need a toolchain that can actually build Miri, just a nightly won't do. run: | cargo install rustup-toolchain-install-master # TODO: cache this? - ./rustup-toolchain "" -c clippy -c rustfmt - - name: rustfmt (miri, ui_test) - run: cargo fmt --all --check - - name: rustfmt (everything else) - # TODO: Add `tests` (work in progress). - # Maybe change to `find . -name '*.rs'`, superseding the previous step. - run: | - find bench-cargo-miri benches cargo-miri test-cargo-miri -name '*.rs' \ - | xargs rustfmt --edition=2021 --config-path ./rustfmt.toml --check + ./rustup-toolchain "" -c clippy + - name: rustfmt + run: ./miri fmt --check - name: clippy (miri) run: cargo clippy --all-targets -- -D warnings #- name: Clippy (ui_test) diff --git a/miri b/miri index 5c9cb81885c9..e89a9e380fff 100755 --- a/miri +++ b/miri @@ -21,10 +21,13 @@ to the final `cargo test` invocation. ./miri run : Build miri, set up a sysroot and then run the driver with the given . -All commands also exist in a "-debug" variant (e.g. "./miri run-debug +The commands above also exist in a "-debug" variant (e.g. "./miri run-debug ") which uses debug builds instead of release builds, for faster build times and slower execution times. +./miri fmt : +Format all sources and tests. are passed to `rustfmt`. + ENVIRONMENT VARIABLES MIRI_SYSROOT: @@ -156,6 +159,10 @@ run|run-debug) # Then run the actual command. exec cargo run $CARGO_BUILD_FLAGS -- --sysroot "$MIRI_SYSROOT" "$@" ;; +fmt) + find "$MIRIDIR" -not \( -name target -prune \) -name '*.rs' \ + | xargs rustfmt --edition=2021 --config-path "$MIRIDIR/rustfmt.toml" "$@" + ;; *) if [ -n "$COMMAND" ]; then echo "Unknown command: $COMMAND" diff --git a/rustup-toolchain b/rustup-toolchain index ca5508e225a1..34472c727f62 100755 --- a/rustup-toolchain +++ b/rustup-toolchain @@ -42,7 +42,7 @@ fi # Install and setup new toolchain. rustup toolchain uninstall miri -rustup-toolchain-install-master -n miri -c cargo -c rust-src -c rustc-dev -c llvm-tools "$@" -- "$NEW_COMMIT" +rustup-toolchain-install-master -n miri -c cargo -c rust-src -c rustc-dev -c llvm-tools -c rustfmt "$@" -- "$NEW_COMMIT" rustup override set miri # Cleanup.