Skip to content

Commit cd43d3a

Browse files
committed
Auto merge of #6329 - dwijnand:disable-autobins, r=alexcrichton
Make autodiscovery disable inferred targets Fixes #6205
2 parents 2ad447f + 8d996a2 commit cd43d3a

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/cargo/util/toml/targets.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,12 @@ fn toml_targets_and_inferred(
634634
) -> Vec<TomlTarget> {
635635
let inferred_targets = inferred_to_toml_targets(inferred);
636636
match toml_targets {
637-
None => inferred_targets,
637+
None =>
638+
if let Some(false) = autodiscover {
639+
vec![]
640+
} else {
641+
inferred_targets
642+
},
638643
Some(targets) => {
639644
let mut targets = targets.clone();
640645

tests/testsuite/run.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,28 @@ fn run_example_autodiscover_2018() {
463463
.run();
464464
}
465465

466+
#[test]
467+
fn autobins_disables() {
468+
let p = project()
469+
.file(
470+
"Cargo.toml",
471+
r#"
472+
[project]
473+
name = "foo"
474+
version = "0.0.1"
475+
autobins = false
476+
"#
477+
)
478+
.file("src/lib.rs", "pub mod bin;")
479+
.file("src/bin/mod.rs", "// empty")
480+
.build();
481+
482+
p.cargo("run")
483+
.with_status(101)
484+
.with_stderr("[ERROR] a bin target must be available for `cargo run`")
485+
.run();
486+
}
487+
466488
#[test]
467489
fn run_bins() {
468490
let p = project()

0 commit comments

Comments
 (0)