about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-05-14 19:28:22 +0000
committerbors <bors@rust-lang.org>2024-05-14 19:28:22 +0000
commitf915c94f388171dedfc515bdbb77cda72f4d2a2c (patch)
tree2cca538833bfc3b7b99848020e9db6c321a4919e /src
parent652426ce656e6ce870100f20dabb5a1307fd2215 (diff)
parentdd0ea024d4b46cd639320be6a14beceda2da703c (diff)
downloadrust-f915c94f388171dedfc515bdbb77cda72f4d2a2c.tar.gz
rust-f915c94f388171dedfc515bdbb77cda72f4d2a2c.zip
Auto merge of #17232 - Veykril:build-scripts-keep-going, r=Veykril
fix: Don't emit --keep-going for custom build script commands

Might be the cause for https://github.com/rust-lang/rust-analyzer/issues/17231
Diffstat (limited to 'src')
-rw-r--r--src/tools/rust-analyzer/crates/project-model/src/build_scripts.rs23
-rw-r--r--src/tools/rust-analyzer/crates/project-model/src/workspace.rs2
2 files changed, 16 insertions, 9 deletions
diff --git a/src/tools/rust-analyzer/crates/project-model/src/build_scripts.rs b/src/tools/rust-analyzer/crates/project-model/src/build_scripts.rs
index 4dc3b3f3498..8e1f7fdcded 100644
--- a/src/tools/rust-analyzer/crates/project-model/src/build_scripts.rs
+++ b/src/tools/rust-analyzer/crates/project-model/src/build_scripts.rs
@@ -64,8 +64,10 @@ impl WorkspaceBuildScripts {
         config: &CargoConfig,
         allowed_features: &FxHashSet<String>,
         manifest_path: &ManifestPath,
+        toolchain: Option<&Version>,
         sysroot: Option<&Sysroot>,
     ) -> io::Result<Command> {
+        const RUST_1_75: Version = Version::new(1, 75, 0);
         let mut cmd = match config.run_build_script_command.as_deref() {
             Some([program, args @ ..]) => {
                 let mut cmd = Command::new(program);
@@ -120,6 +122,10 @@ impl WorkspaceBuildScripts {
                     cmd.arg("-Zscript");
                 }
 
+                if toolchain.map_or(false, |it| *it >= RUST_1_75) {
+                    cmd.arg("--keep-going");
+                }
+
                 cmd
             }
         };
@@ -142,11 +148,9 @@ impl WorkspaceBuildScripts {
         config: &CargoConfig,
         workspace: &CargoWorkspace,
         progress: &dyn Fn(String),
-        toolchain: &Option<Version>,
+        toolchain: Option<&Version>,
         sysroot: Option<&Sysroot>,
     ) -> io::Result<WorkspaceBuildScripts> {
-        const RUST_1_75: Version = Version::new(1, 75, 0);
-
         let current_dir = match &config.invocation_location {
             InvocationLocation::Root(root) if config.run_build_script_command.is_some() => {
                 root.as_path()
@@ -156,11 +160,13 @@ impl WorkspaceBuildScripts {
         .as_ref();
 
         let allowed_features = workspace.workspace_features();
-        let mut cmd =
-            Self::build_command(config, &allowed_features, workspace.manifest_path(), sysroot)?;
-        if toolchain.as_ref().map_or(false, |it| *it >= RUST_1_75) {
-            cmd.args(["--keep-going"]);
-        }
+        let cmd = Self::build_command(
+            config,
+            &allowed_features,
+            workspace.manifest_path(),
+            toolchain,
+            sysroot,
+        )?;
         Self::run_per_ws(cmd, workspace, current_dir, progress)
     }
 
@@ -189,6 +195,7 @@ impl WorkspaceBuildScripts {
             // This is not gonna be used anyways, so just construct a dummy here
             &ManifestPath::try_from(workspace_root.clone()).unwrap(),
             None,
+            None,
         )?;
         // NB: Cargo.toml could have been modified between `cargo metadata` and
         // `cargo check`. We shouldn't assume that package ids we see here are
diff --git a/src/tools/rust-analyzer/crates/project-model/src/workspace.rs b/src/tools/rust-analyzer/crates/project-model/src/workspace.rs
index 3e927b2935b..85621444e33 100644
--- a/src/tools/rust-analyzer/crates/project-model/src/workspace.rs
+++ b/src/tools/rust-analyzer/crates/project-model/src/workspace.rs
@@ -488,7 +488,7 @@ impl ProjectWorkspace {
                     config,
                     cargo,
                     progress,
-                    &self.toolchain,
+                    self.toolchain.as_ref(),
                     self.sysroot.as_ref().ok(),
                 )
                 .with_context(|| {