Skip to content

Commit 3fc0715

Browse files
committed
Make the default behaviour of cargo build match the documentation
cargo build --help says: --all-targets Build all targets (lib and bin targets by default) but the old default behaviour was actually doing --all-targets. This meant that --avoid-dev-deps was only effectively if one gave --lib --bins explicitly. With this commit, `cargo build --avoid-dev-deps` with no other flags, will build lib and bins and avoid installing dev-dependencies.
1 parent ee78456 commit 3fc0715

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/cargo/ops/cargo_compile.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -421,15 +421,19 @@ impl<'a> CompileFilter<'a> {
421421

422422
pub fn need_dev_deps(&self) -> bool {
423423
match *self {
424-
CompileFilter::Default { .. } => true,
424+
CompileFilter::Default { .. } => false,
425425
CompileFilter::Only { examples, tests, benches, .. } =>
426426
examples.is_specific() || tests.is_specific() || benches.is_specific()
427427
}
428428
}
429429

430430
pub fn matches(&self, target: &Target) -> bool {
431431
match *self {
432-
CompileFilter::Default { .. } => true,
432+
CompileFilter::Default { .. } => match *target.kind() {
433+
TargetKind::Bin => true,
434+
TargetKind::Lib(..) => true,
435+
_ => false,
436+
},
433437
CompileFilter::Only { lib, bins, examples, tests, benches, .. } => {
434438
let rule = match *target.kind() {
435439
TargetKind::Bin => bins,

0 commit comments

Comments
 (0)