about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorLukas Wirth <me@lukaswirth.dev>2025-07-03 11:03:36 +0000
committerGitHub <noreply@github.com>2025-07-03 11:03:36 +0000
commit2a4b4ff42fa1ea8a6df0f162ea6fa66933dd8d9c (patch)
tree6ac3ce9bf460c5a6bf71cd9ffaf4e1c7a5da8988 /src
parent4a6bd408f13ceeeda08df4554b1074e69e4a4254 (diff)
parentea88dbedc99e2d4d68d1359e75f2da77e130c6f8 (diff)
downloadrust-2a4b4ff42fa1ea8a6df0f162ea6fa66933dd8d9c.tar.gz
rust-2a4b4ff42fa1ea8a6df0f162ea6fa66933dd8d9c.zip
Merge pull request #20159 from Veykril/push-kyssnlrxlwsl
Always couple `--compile-time-deps` with
Diffstat (limited to 'src')
-rw-r--r--src/tools/rust-analyzer/crates/project-model/src/build_dependencies.rs35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/tools/rust-analyzer/crates/project-model/src/build_dependencies.rs b/src/tools/rust-analyzer/crates/project-model/src/build_dependencies.rs
index bbaa8f4f292..adbaa8ef8da 100644
--- a/src/tools/rust-analyzer/crates/project-model/src/build_dependencies.rs
+++ b/src/tools/rust-analyzer/crates/project-model/src/build_dependencies.rs
@@ -409,13 +409,6 @@ impl WorkspaceBuildScripts {
                     cmd.arg("--target-dir").arg(target_dir);
                 }
 
-                // --all-targets includes tests, benches and examples in addition to the
-                // default lib and bins. This is an independent concept from the --target
-                // flag below.
-                if config.all_targets {
-                    cmd.arg("--all-targets");
-                }
-
                 if let Some(target) = &config.target {
                     cmd.args(["--target", target]);
                 }
@@ -463,14 +456,26 @@ impl WorkspaceBuildScripts {
                     cmd.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly");
                     cmd.arg("-Zunstable-options");
                     cmd.arg("--compile-time-deps");
-                } else if config.wrap_rustc_in_build_scripts {
-                    // Setup RUSTC_WRAPPER to point to `rust-analyzer` binary itself. We use
-                    // that to compile only proc macros and build scripts during the initial
-                    // `cargo check`.
-                    // We don't need this if we are using `--compile-time-deps` flag.
-                    let myself = std::env::current_exe()?;
-                    cmd.env("RUSTC_WRAPPER", myself);
-                    cmd.env("RA_RUSTC_WRAPPER", "1");
+                    // we can pass this unconditionally, because we won't actually build the
+                    // binaries, and as such, this will succeed even on targets without libtest
+                    cmd.arg("--all-targets");
+                } else {
+                    // --all-targets includes tests, benches and examples in addition to the
+                    // default lib and bins. This is an independent concept from the --target
+                    // flag below.
+                    if config.all_targets {
+                        cmd.arg("--all-targets");
+                    }
+
+                    if config.wrap_rustc_in_build_scripts {
+                        // Setup RUSTC_WRAPPER to point to `rust-analyzer` binary itself. We use
+                        // that to compile only proc macros and build scripts during the initial
+                        // `cargo check`.
+                        // We don't need this if we are using `--compile-time-deps` flag.
+                        let myself = std::env::current_exe()?;
+                        cmd.env("RUSTC_WRAPPER", myself);
+                        cmd.env("RA_RUSTC_WRAPPER", "1");
+                    }
                 }
                 Ok(cmd)
             }