Skip to content

Commit 9ecdc9e

Browse files
committed
Auto merge of #2381 - rust-lang:infra, r=RalfJung
Add a scheme for always using the default toolchain, running clippy and fmt before running any other command I keep forgetting to run rustup-toolchain on rebases across toolchain updates I also keep forgetting to run rustfmt and clippy. The former isn't run by vscode if I don't explicitly save (I have autosave on).
2 parents e8c4c9a + 4d4eeca commit 9ecdc9e

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
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: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,34 @@ Pass extra flags to all cargo invocations.
4848
EOF
4949
)
5050

51-
## Preparation
51+
## We need to know where we are.
5252
# macOS does not have a useful readlink/realpath so we have to use Python instead...
5353
MIRIDIR=$(python3 -c 'import os, sys; print(os.path.dirname(os.path.realpath(sys.argv[1])))' "$0")
54-
TOOLCHAIN=$(cd "$MIRIDIR"; rustup show active-toolchain | head -n 1 | cut -d ' ' -f 1)
5554

56-
# Determine command.
55+
## Run the auto-things.
56+
if [ -z "$AUTO_OPS" ]; then
57+
export AUTO_OPS=42
58+
59+
# Run this first, so that the toolchain doesn't change after
60+
# other code has run.
61+
if [ -f "$MIRIDIR/.auto-everything" ] || [ -f "$MIRIDIR/.auto-toolchain" ] ; then
62+
"$MIRIDIR"/rustup-toolchain
63+
fi
64+
65+
if [ -f "$MIRIDIR/.auto-everything" ] || [ -f "$MIRIDIR/.auto-fmt" ] ; then
66+
$0 fmt
67+
fi
68+
69+
if [ -f "$MIRIDIR/.auto-everything" ] || [ -f "$MIRIDIR/.auto-clippy" ] ; then
70+
$0 clippy -- -D warnings
71+
fi
72+
fi
73+
74+
## Determine command and toolchain.
5775
COMMAND="$1"
5876
[ $# -gt 0 ] && shift
77+
# Doing this *after* auto-toolchain logic above, since that might change the toolchain.
78+
TOOLCHAIN=$(cd "$MIRIDIR"; rustup show active-toolchain | head -n 1 | cut -d ' ' -f 1)
5979

6080
## Handle some commands early, since they should *not* alter the environment.
6181
case "$COMMAND" in

0 commit comments

Comments
 (0)