Skip to content

Commit 22c0f22

Browse files
committed
Auto merge of #5556 - alexcrichton:fix, r=matklad
Copy `--all-features` request to all workspace members This fixes an accidental regression introduced in #5012 where the `--all-features` CLI flag was only propagated to the "main crate" as opposed to all workspace packages. This behavior has [already been deemed][pr] as "basically not what you want", but for now it's best to avoid the regression. Closes #5518 [pr]: #5353
2 parents e85856a + a70d519 commit 22c0f22

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

src/cargo/ops/resolve.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,11 @@ pub fn resolve_with_previous<'a, 'cfg>(
272272
// workspace, then we use `method` specified. Otherwise we use a
273273
// base method with no features specified but using default features
274274
// for any other packages specified with `-p`.
275-
Method::Required { dev_deps, .. } => {
275+
Method::Required { dev_deps, all_features, .. } => {
276276
let base = Method::Required {
277277
dev_deps,
278278
features: &[],
279-
all_features: false,
279+
all_features,
280280
uses_default_features: true,
281281
};
282282
let member_id = member.package_id();

tests/testsuite/features.rs

+39
Original file line numberDiff line numberDiff line change
@@ -2031,3 +2031,42 @@ fn only_dep_is_optional() {
20312031
execs().with_status(0),
20322032
);
20332033
}
2034+
2035+
#[test]
2036+
fn all_features_all_crates() {
2037+
Package::new("bar", "0.1.0").publish();
2038+
2039+
let p = project("foo")
2040+
.file(
2041+
"Cargo.toml",
2042+
r#"
2043+
[project]
2044+
name = "foo"
2045+
version = "0.0.1"
2046+
authors = []
2047+
2048+
[workspace]
2049+
members = ['bar']
2050+
"#,
2051+
)
2052+
.file("src/main.rs", "fn main() {}")
2053+
.file(
2054+
"bar/Cargo.toml",
2055+
r#"
2056+
[project]
2057+
name = "bar"
2058+
version = "0.0.1"
2059+
authors = []
2060+
2061+
[features]
2062+
foo = []
2063+
"#,
2064+
)
2065+
.file("bar/src/main.rs", "#[cfg(feature = \"foo\")] fn main() {}")
2066+
.build();
2067+
2068+
assert_that(
2069+
p.cargo("build --all-features --all"),
2070+
execs().with_status(0),
2071+
);
2072+
}

0 commit comments

Comments
 (0)