Skip to content

Commit d95b29b

Browse files
committed
Auto merge of #9584 - henrifrancois:master, r=ehuss
Handle "jobs = 0" case in cargo config files Cargo hangs without output if the jobs argument under build in a cargo/config file is set to 0. This PR handles this case by providing an appropriate error. Closes #9219
2 parents 40df0f1 + 0663b71 commit d95b29b

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/cargo/core/compiler/build_config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ impl BuildConfig {
6969
)?;
7070
}
7171
let jobs = jobs.or(cfg.jobs).unwrap_or(::num_cpus::get() as u32);
72+
if jobs == 0 {
73+
anyhow::bail!("jobs may not be 0");
74+
}
7275

7376
Ok(BuildConfig {
7477
requested_kinds,

tests/testsuite/build.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4802,6 +4802,24 @@ fn good_cargo_config_jobs() {
48024802
p.cargo("build -v").run();
48034803
}
48044804

4805+
#[cargo_test]
4806+
fn invalid_cargo_config_jobs() {
4807+
let p = project()
4808+
.file("src/lib.rs", "")
4809+
.file(
4810+
".cargo/config",
4811+
r#"
4812+
[build]
4813+
jobs = 0
4814+
"#,
4815+
)
4816+
.build();
4817+
p.cargo("build -v")
4818+
.with_status(101)
4819+
.with_stderr_contains("error: jobs may not be 0")
4820+
.run();
4821+
}
4822+
48054823
#[cargo_test]
48064824
fn invalid_jobs() {
48074825
let p = project()

0 commit comments

Comments
 (0)