diff options
| author | Lukas Wirth <me@lukaswirth.dev> | 2025-07-03 12:52:32 +0200 |
|---|---|---|
| committer | Lukas Wirth <me@lukaswirth.dev> | 2025-07-03 12:52:32 +0200 |
| commit | ea88dbedc99e2d4d68d1359e75f2da77e130c6f8 (patch) | |
| tree | b482a65b8859c9ee18ec854821561df854efa35f /src/tools/rust-analyzer | |
| parent | f98e4d05a1b9bb5cc15a70bbc024a7017d27b9af (diff) | |
| download | rust-ea88dbedc99e2d4d68d1359e75f2da77e130c6f8.tar.gz rust-ea88dbedc99e2d4d68d1359e75f2da77e130c6f8.zip | |
Always couple `--compile-time-deps` with
`--all-targets` coupled with `--compile-time-deps` will never actually build binaries and so it won't fail for targets where libtest is missing
Diffstat (limited to 'src/tools/rust-analyzer')
| -rw-r--r-- | src/tools/rust-analyzer/crates/project-model/src/build_dependencies.rs | 35 |
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) } |
