Skip to content

Commit

Permalink
Auto merge of #6329 - dwijnand:disable-autobins, r=alexcrichton
Browse files Browse the repository at this point in the history
Make autodiscovery disable inferred targets

Fixes #6205
  • Loading branch information
bors committed Nov 19, 2018
2 parents 2ad447f + 8d996a2 commit cd43d3a
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 cd43d3a

Please sign in to comment.