Skip to content

Commit 828d41f

Browse files
committed
adjust the way we build miri-script in RA, to fix proc-macros
1 parent bd99bc7 commit 828d41f

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

etc/rust_analyzer_vscode.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,19 @@
55
"cargo-miri/Cargo.toml",
66
"miri-script/Cargo.toml",
77
],
8-
"rust-analyzer.check.invocationLocation": "root",
98
"rust-analyzer.check.invocationStrategy": "once",
109
"rust-analyzer.check.overrideCommand": [
11-
"env",
12-
"MIRI_AUTO_OPS=no",
1310
"./miri",
1411
"clippy", // make this `check` when working with a locally built rustc
1512
"--message-format=json",
1613
],
14+
"rust-analyzer.cargo.extraEnv": {
15+
"MIRI_AUTO_OPS": "no",
16+
"MIRI_IN_RA": "1",
17+
},
1718
// Contrary to what the name suggests, this also affects proc macros.
18-
"rust-analyzer.cargo.buildScripts.invocationLocation": "root",
1919
"rust-analyzer.cargo.buildScripts.invocationStrategy": "once",
2020
"rust-analyzer.cargo.buildScripts.overrideCommand": [
21-
"env",
22-
"MIRI_AUTO_OPS=no",
2321
"./miri",
2422
"check",
2523
"--message-format=json",

miri

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ set -e
33
# We want to call the binary directly, so we need to know where it ends up.
44
ROOT_DIR="$(dirname "$0")"
55
MIRI_SCRIPT_TARGET_DIR="$ROOT_DIR"/miri-script/target
6-
# If stdout is not a terminal and we are not on CI, assume that we are being invoked by RA, and use JSON output.
7-
if ! [ -t 1 ] && [ -z "$CI" ]; then
6+
TOOLCHAIN="+nightly"
7+
# If we are being invoked for RA, use JSON output and the default toolchain (to make proc-macros
8+
# work in RA). This needs a different target dir to avoid mixing up the builds.
9+
if [ -n "$MIRI_IN_RA" ]; then
810
MESSAGE_FORMAT="--message-format=json"
11+
TOOLCHAIN=""
12+
MIRI_SCRIPT_TARGET_DIR="$MIRI_SCRIPT_TARGET_DIR"/ra
913
fi
1014
# We need a nightly toolchain, for `-Zroot-dir`.
11-
cargo +nightly build $CARGO_EXTRA_FLAGS --manifest-path "$ROOT_DIR"/miri-script/Cargo.toml \
15+
cargo $TOOLCHAIN build $CARGO_EXTRA_FLAGS --manifest-path "$ROOT_DIR"/miri-script/Cargo.toml \
1216
-Zroot-dir="$ROOT_DIR" \
1317
-q --target-dir "$MIRI_SCRIPT_TARGET_DIR" $MESSAGE_FORMAT || \
1418
( echo "Failed to build miri-script. Is the 'nightly' toolchain installed?"; exit 1 )

0 commit comments

Comments
 (0)