Skip to content

Commit ab88e64

Browse files
committed
Auto merge of #2495 - RalfJung:ra, r=RalfJung
add ./miri cargo for RA to invoke RA expects a check command to check *individual workspaces*, whereas `./miri` is designed to check/build/test all parts of Miri. So add a new `./miri cargo` that performs just a single cargo invocation, but with the right env vars so that the build cache can be shared with `./miri check`.
2 parents 1a03e30 + 0c3ad68 commit ab88e64

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,16 @@ to `.vscode/settings.json` in your local Miri clone:
171171
"env",
172172
"MIRI_AUTO_OPS=no",
173173
"./miri",
174-
"check",
174+
"cargo",
175+
"clippy", // make this `check` when working with a locally built rustc
175176
"--message-format=json"
176177
],
177178
// Contrary to what the name suggests, this also affects proc macros.
178179
"rust-analyzer.cargo.buildScripts.overrideCommand": [
179180
"env",
180181
"MIRI_AUTO_OPS=no",
181182
"./miri",
183+
"cargo",
182184
"check",
183185
"--message-format=json",
184186
],

cargo-miri/miri

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
2-
# Hack to work around https://github.com/rust-analyzer/rust-analyzer/issues/10793.
2+
# RA invokes `./miri cargo ...` for each workspace, so we need to forward that to the main `miri`
3+
# script. See <https://github.com/rust-analyzer/rust-analyzer/issues/10793>.
34
exec "$(dirname "$0")"/../miri "$@"

miri

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ Format all sources and tests. <flags> are passed to `rustfmt`.
2929
./miri clippy <flags>:
3030
Runs clippy on all sources. <flags> are passed to `cargo clippy`.
3131
32+
./miri cargo <flags>:
33+
Runs just `cargo <flags>` with the Miri-specific environment variables.
34+
Mainly meant to be invoked by rust-analyzer.
35+
3236
./miri many-seeds <command>:
3337
Runs <command> over and over again with different seeds for Miri. The MIRIFLAGS
3438
variable is set to its original value appended with ` -Zmiri-seed=$SEED` for
@@ -44,7 +48,7 @@ MIRI_SYSROOT:
4448
If already set, the "sysroot setup" step is skipped.
4549
4650
CARGO_EXTRA_FLAGS:
47-
Pass extra flags to all cargo invocations.
51+
Pass extra flags to all cargo invocations. (Ignored by `./miri cargo`.)
4852
EOF
4953
)
5054

@@ -218,6 +222,11 @@ clippy)
218222
$CARGO clippy $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/ui_test/Cargo.toml --all-targets "$@"
219223
$CARGO clippy $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml "$@"
220224
;;
225+
cargo)
226+
# We carefully kept the working dir intact, so this will run cargo *on the workspace in the
227+
# current working dir*, not on the main Miri workspace. That is exactly what RA needs.
228+
$CARGO "$@"
229+
;;
221230
*)
222231
if [ -n "$COMMAND" ]; then
223232
echo "Unknown command: $COMMAND"

0 commit comments

Comments
 (0)