Skip to content

Commit cd90e11

Browse files
committed
Auto merge of rust-lang#2257 - dtolnay-contrib:rustfmt9, r=RalfJung
Add `./miri fmt` and check in CI
2 parents b84754b + e5f40ca commit cd90e11

File tree

7 files changed

+17
-14
lines changed

7 files changed

+17
-14
lines changed

.github/workflows/ci.yml

+3-9
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

+8-1
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

+1-1
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.

tests/fail/abort-terminator.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![feature(c_unwind)]
22

3-
extern "C" fn panic_abort() { //~ ERROR: the program aborted
3+
extern "C" fn panic_abort() {
4+
//~^ ERROR: the program aborted
45
panic!()
56
}
67

tests/fail/abort-terminator.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ error: abnormal termination: the program aborted execution
44
--> $DIR/abort-terminator.rs:LL:CC
55
|
66
LL | / extern "C" fn panic_abort() {
7+
LL | |
78
LL | | panic!()
89
LL | | }
910
| |_^ the program aborted execution

tests/fail/concurrency/unwind_top_of_stack.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extern crate libc;
1010
use std::{mem, ptr};
1111

1212
extern "C-unwind" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void {
13-
//~^ ERROR unwinding past the topmost frame of the stack
13+
//~^ ERROR unwinding past the topmost frame of the stack
1414
panic!()
1515
}
1616

tests/pass/concurrency/sync_nopreempt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// We are making scheduler assumptions here.
33
// compile-flags: -Zmiri-strict-provenance -Zmiri-preemption-rate=0
44

5-
use std::sync::{Condvar, Mutex, Arc};
5+
use std::sync::{Arc, Condvar, Mutex};
66
use std::thread;
77

88
fn check_conditional_variables_notify_all() {

0 commit comments

Comments
 (0)