Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 2cbc461

Browse files
committed
Add './miri fmt' and use it in CI
1 parent b84754b commit 2cbc461

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,9 @@ jobs:
9595
# We need a toolchain that can actually build Miri, just a nightly won't do.
9696
run: |
9797
cargo install rustup-toolchain-install-master # TODO: cache this?
98-
./rustup-toolchain "" -c clippy -c rustfmt
99-
- name: rustfmt (miri, ui_test)
100-
run: cargo fmt --all --check
101-
- name: rustfmt (everything else)
102-
# TODO: Add `tests` (work in progress).
103-
# Maybe change to `find . -name '*.rs'`, superseding the previous step.
104-
run: |
105-
find bench-cargo-miri benches cargo-miri test-cargo-miri -name '*.rs' \
106-
| xargs rustfmt --edition=2021 --config-path ./rustfmt.toml --check
98+
./rustup-toolchain "" -c clippy
99+
- name: rustfmt
100+
run: ./miri fmt --check
107101
- name: clippy (miri)
108102
run: cargo clippy --all-targets -- -D warnings
109103
#- name: Clippy (ui_test)

miri

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ to the final `cargo test` invocation.
2121
./miri run <flags>:
2222
Build miri, set up a sysroot and then run the driver with the given <flags>.
2323
24-
All commands also exist in a "-debug" variant (e.g. "./miri run-debug
24+
The commands above also exist in a "-debug" variant (e.g. "./miri run-debug
2525
<flags>") which uses debug builds instead of release builds, for faster build
2626
times and slower execution times.
2727
28+
./miri fmt <flags>:
29+
Format all sources and tests. <flags> are passed to `rustfmt`.
30+
2831
ENVIRONMENT VARIABLES
2932
3033
MIRI_SYSROOT:
@@ -156,6 +159,10 @@ run|run-debug)
156159
# Then run the actual command.
157160
exec cargo run $CARGO_BUILD_FLAGS -- --sysroot "$MIRI_SYSROOT" "$@"
158161
;;
162+
fmt)
163+
find "$MIRIDIR" -not \( -name target -prune \) -name '*.rs' \
164+
| xargs rustfmt --edition=2021 --config-path "$MIRIDIR/rustfmt.toml" "$@"
165+
;;
159166
*)
160167
if [ -n "$COMMAND" ]; then
161168
echo "Unknown command: $COMMAND"

rustup-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fi
4242

4343
# Install and setup new toolchain.
4444
rustup toolchain uninstall miri
45-
rustup-toolchain-install-master -n miri -c cargo -c rust-src -c rustc-dev -c llvm-tools "$@" -- "$NEW_COMMIT"
45+
rustup-toolchain-install-master -n miri -c cargo -c rust-src -c rustc-dev -c llvm-tools -c rustfmt "$@" -- "$NEW_COMMIT"
4646
rustup override set miri
4747

4848
# Cleanup.

0 commit comments

Comments
 (0)