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

Commit 517e1d7

Browse files
oli-obkRalfJung
authored andcommitted
Add a scheme for always using the default toolchain, running clippy and fmt before running any other command
1 parent e8c4c9a commit 517e1d7

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ tex/*/out
88
perf.data
99
perf.data.old
1010
flamegraph.svg
11+
.auto-*

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ install that exact version of rustc as a toolchain:
2828
This will set up a rustup toolchain called `miri` and set it as an override for
2929
the current directory.
3030

31+
You can also create a `.auto-everything` file (contents don't matter, can be empty), which
32+
will cause any `./miri` command to automatically call `rustup-toolchain`, `clippy` and `rustfmt`
33+
for you. If you don't want all of these to happen, you can add individual `.auto-toolchain`,
34+
`.auto-clippy` and `.auto-fmt` files respectively.
35+
3136
[`rustup-toolchain-install-master`]: https://github.com/kennytm/rustup-toolchain-install-master
3237

3338
## Building and testing Miri
@@ -244,6 +249,14 @@ rustup toolchain link stage2 build/x86_64-unknown-linux-gnu/stage2
244249
rustup override set stage2
245250
```
246251

252+
Note: When you are working with a locally built rustc or any other toolchain that
253+
is not the same as the one in `rust-version`, you should not have `.auto-everything` or
254+
`.auto-toolchain` as that will keep resetting your toolchain.
255+
256+
```
257+
rm -f .auto-everything .auto-toolchain
258+
```
259+
247260
Important: You need to delete the Miri cache when you change the stdlib; otherwise the
248261
old, chached version will be used. On Linux, the cache is located at `~/.cache/miri`,
249262
and on Windows, it is located at `%LOCALAPPDATA%\rust-lang\miri\cache`; the exact

miri

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,25 @@ Pass extra flags to all cargo invocations.
4848
EOF
4949
)
5050

51+
## Run the subcommands that the user requested to always run first
52+
if [ -z "$AUTO_OPS" ]; then
53+
export AUTO_OPS=42
54+
55+
# Run this first, so that the toolchain doesn't change after
56+
# other code has run.
57+
if [ -f ".auto-everything" ] || [ -f ".auto-toolchain" ] ; then
58+
"$MIRIDIR"/rustup-toolchain
59+
fi
60+
61+
if [ -f ".auto-everything" ] || [ -f ".auto-fmt" ] ; then
62+
$0 fmt
63+
fi
64+
65+
if [ -f ".auto-everything" ] || [ -f ".auto-clippy" ] ; then
66+
$0 clippy -- -D warnings
67+
fi
68+
fi
69+
5170
## Preparation
5271
# macOS does not have a useful readlink/realpath so we have to use Python instead...
5372
MIRIDIR=$(python3 -c 'import os, sys; print(os.path.dirname(os.path.realpath(sys.argv[1])))' "$0")

0 commit comments

Comments
 (0)