Skip to content

Commit f915c94

Browse files
committed
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 rust-lang/rust-analyzer#17231
2 parents 652426c + dd0ea02 commit f915c94

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/tools/rust-analyzer/crates/project-model/src/build_scripts.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ impl WorkspaceBuildScripts {
6464
config: &CargoConfig,
6565
allowed_features: &FxHashSet<String>,
6666
manifest_path: &ManifestPath,
67+
toolchain: Option<&Version>,
6768
sysroot: Option<&Sysroot>,
6869
) -> io::Result<Command> {
70+
const RUST_1_75: Version = Version::new(1, 75, 0);
6971
let mut cmd = match config.run_build_script_command.as_deref() {
7072
Some([program, args @ ..]) => {
7173
let mut cmd = Command::new(program);
@@ -120,6 +122,10 @@ impl WorkspaceBuildScripts {
120122
cmd.arg("-Zscript");
121123
}
122124

125+
if toolchain.map_or(false, |it| *it >= RUST_1_75) {
126+
cmd.arg("--keep-going");
127+
}
128+
123129
cmd
124130
}
125131
};
@@ -142,11 +148,9 @@ impl WorkspaceBuildScripts {
142148
config: &CargoConfig,
143149
workspace: &CargoWorkspace,
144150
progress: &dyn Fn(String),
145-
toolchain: &Option<Version>,
151+
toolchain: Option<&Version>,
146152
sysroot: Option<&Sysroot>,
147153
) -> io::Result<WorkspaceBuildScripts> {
148-
const RUST_1_75: Version = Version::new(1, 75, 0);
149-
150154
let current_dir = match &config.invocation_location {
151155
InvocationLocation::Root(root) if config.run_build_script_command.is_some() => {
152156
root.as_path()
@@ -156,11 +160,13 @@ impl WorkspaceBuildScripts {
156160
.as_ref();
157161

158162
let allowed_features = workspace.workspace_features();
159-
let mut cmd =
160-
Self::build_command(config, &allowed_features, workspace.manifest_path(), sysroot)?;
161-
if toolchain.as_ref().map_or(false, |it| *it >= RUST_1_75) {
162-
cmd.args(["--keep-going"]);
163-
}
163+
let cmd = Self::build_command(
164+
config,
165+
&allowed_features,
166+
workspace.manifest_path(),
167+
toolchain,
168+
sysroot,
169+
)?;
164170
Self::run_per_ws(cmd, workspace, current_dir, progress)
165171
}
166172

@@ -189,6 +195,7 @@ impl WorkspaceBuildScripts {
189195
// This is not gonna be used anyways, so just construct a dummy here
190196
&ManifestPath::try_from(workspace_root.clone()).unwrap(),
191197
None,
198+
None,
192199
)?;
193200
// NB: Cargo.toml could have been modified between `cargo metadata` and
194201
// `cargo check`. We shouldn't assume that package ids we see here are

src/tools/rust-analyzer/crates/project-model/src/workspace.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ impl ProjectWorkspace {
488488
config,
489489
cargo,
490490
progress,
491-
&self.toolchain,
491+
self.toolchain.as_ref(),
492492
self.sysroot.as_ref().ok(),
493493
)
494494
.with_context(|| {

0 commit comments

Comments
 (0)