Skip to content

Commit

Permalink
Make autodiscovery disable inferred targets
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Nov 18, 2018
1 parent 53e436d commit 8d996a2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/cargo/util/toml/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,12 @@ fn toml_targets_and_inferred(
) -> Vec<TomlTarget> {
let inferred_targets = inferred_to_toml_targets(inferred);
match toml_targets {
None => inferred_targets,
None =>
if let Some(false) = autodiscover {
vec![]
} else {
inferred_targets
},
Some(targets) => {
let mut targets = targets.clone();

Expand Down
22 changes: 22 additions & 0 deletions tests/testsuite/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,28 @@ fn run_example_autodiscover_2018() {
.run();
}

#[test]
fn autobins_disables() {
let p = project()
.file(
"Cargo.toml",
r#"
[project]
name = "foo"
version = "0.0.1"
autobins = false
"#
)
.file("src/lib.rs", "pub mod bin;")
.file("src/bin/mod.rs", "// empty")
.build();

p.cargo("run")
.with_status(101)
.with_stderr("[ERROR] a bin target must be available for `cargo run`")
.run();
}

#[test]
fn run_bins() {
let p = project()
Expand Down

0 comments on commit 8d996a2

Please sign in to comment.