diff --git a/src/cargo/core/compiler/unit_dependencies.rs b/src/cargo/core/compiler/unit_dependencies.rs index 48095cdb16c..7c5bd04f0e8 100644 --- a/src/cargo/core/compiler/unit_dependencies.rs +++ b/src/cargo/core/compiler/unit_dependencies.rs @@ -266,7 +266,7 @@ fn compute_deps<'a, 'cfg>( Some(pkg) => pkg, None => continue, }; - let lib = match pkg.targets().iter().find(|t| t.is_lib()) { + let lib = match pkg.targets().iter().find(|t| t.is_lib() || t.is_bin()) { Some(t) => t, None => continue, }; diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 50b49ea7ea4..7c163b834c2 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -2194,6 +2194,8 @@ fn rebuild_preserves_out_dir() { #[cargo_test] fn dep_no_libs() { + let exe_name = format!("bar{}", env::consts::EXE_SUFFIX); + let foo = project() .file( "Cargo.toml", @@ -2209,9 +2211,11 @@ fn dep_no_libs() { ) .file("src/lib.rs", "pub fn bar() -> i32 { 1 }") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.0")) - .file("bar/src/main.rs", "") + .file("bar/src/main.rs", "fn main() {}") .build(); + foo.cargo("build").run(); + assert!(foo.target_debug_dir().join(exe_name).exists()); } #[cargo_test]