Skip to content

Commit 0b6f420

Browse files
committed
Put namespaced features behind a feature gate
1 parent f5a4282 commit 0b6f420

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

src/cargo/core/features.rs

+3
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ features! {
177177

178178
// Overriding profiles for dependencies.
179179
[unstable] profile_overrides: bool,
180+
181+
// Separating the namespaces for features and dependencies
182+
[unstable] namespaced_features: bool,
180183
}
181184
}
182185

src/cargo/util/toml/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,9 @@ impl TomlManifest {
839839

840840
let exclude = project.exclude.clone().unwrap_or_default();
841841
let include = project.include.clone().unwrap_or_default();
842+
if project.namespaced_features.is_some() {
843+
features.require(Feature::namespaced_features())?;
844+
}
842845

843846
let summary = Summary::new(
844847
pkgid,

tests/testsuite/features.rs

+30-8
Original file line numberDiff line numberDiff line change
@@ -1721,6 +1721,8 @@ fn namespaced_invalid_feature() {
17211721
.file(
17221722
"Cargo.toml",
17231723
r#"
1724+
cargo-features = ["namespaced-features"]
1725+
17241726
[project]
17251727
name = "foo"
17261728
version = "0.0.1"
@@ -1735,7 +1737,7 @@ fn namespaced_invalid_feature() {
17351737
.build();
17361738

17371739
assert_that(
1738-
p.cargo("build"),
1740+
p.cargo("build").masquerade_as_nightly_cargo(),
17391741
execs().with_status(101).with_stderr(
17401742
"\
17411743
[ERROR] failed to parse manifest at `[..]`
@@ -1753,6 +1755,8 @@ fn namespaced_invalid_dependency() {
17531755
.file(
17541756
"Cargo.toml",
17551757
r#"
1758+
cargo-features = ["namespaced-features"]
1759+
17561760
[project]
17571761
name = "foo"
17581762
version = "0.0.1"
@@ -1767,7 +1771,7 @@ fn namespaced_invalid_dependency() {
17671771
.build();
17681772

17691773
assert_that(
1770-
p.cargo("build"),
1774+
p.cargo("build").masquerade_as_nightly_cargo(),
17711775
execs().with_status(101).with_stderr(
17721776
"\
17731777
[ERROR] failed to parse manifest at `[..]`
@@ -1785,6 +1789,8 @@ fn namespaced_non_optional_dependency() {
17851789
.file(
17861790
"Cargo.toml",
17871791
r#"
1792+
cargo-features = ["namespaced-features"]
1793+
17881794
[project]
17891795
name = "foo"
17901796
version = "0.0.1"
@@ -1802,7 +1808,7 @@ fn namespaced_non_optional_dependency() {
18021808
.build();
18031809

18041810
assert_that(
1805-
p.cargo("build"),
1811+
p.cargo("build").masquerade_as_nightly_cargo(),
18061812
execs().with_status(101).with_stderr(
18071813
"\
18081814
[ERROR] failed to parse manifest at `[..]`
@@ -1821,6 +1827,8 @@ fn namespaced_implicit_feature() {
18211827
.file(
18221828
"Cargo.toml",
18231829
r#"
1830+
cargo-features = ["namespaced-features"]
1831+
18241832
[project]
18251833
name = "foo"
18261834
version = "0.0.1"
@@ -1837,7 +1845,10 @@ fn namespaced_implicit_feature() {
18371845
.file("src/main.rs", "fn main() {}")
18381846
.build();
18391847

1840-
assert_that(p.cargo("build"), execs().with_status(0));
1848+
assert_that(
1849+
p.cargo("build").masquerade_as_nightly_cargo(),
1850+
execs().with_status(0),
1851+
);
18411852
}
18421853

18431854
#[test]
@@ -1846,6 +1857,8 @@ fn namespaced_shadowed_dep() {
18461857
.file(
18471858
"Cargo.toml",
18481859
r#"
1860+
cargo-features = ["namespaced-features"]
1861+
18491862
[project]
18501863
name = "foo"
18511864
version = "0.0.1"
@@ -1863,7 +1876,7 @@ fn namespaced_shadowed_dep() {
18631876
.build();
18641877

18651878
assert_that(
1866-
p.cargo("build"),
1879+
p.cargo("build").masquerade_as_nightly_cargo(),
18671880
execs().with_status(101).with_stderr(
18681881
"\
18691882
[ERROR] failed to parse manifest at `[..]`
@@ -1882,6 +1895,8 @@ fn namespaced_shadowed_non_optional() {
18821895
.file(
18831896
"Cargo.toml",
18841897
r#"
1898+
cargo-features = ["namespaced-features"]
1899+
18851900
[project]
18861901
name = "foo"
18871902
version = "0.0.1"
@@ -1899,7 +1914,7 @@ fn namespaced_shadowed_non_optional() {
18991914
.build();
19001915

19011916
assert_that(
1902-
p.cargo("build"),
1917+
p.cargo("build").masquerade_as_nightly_cargo(),
19031918
execs().with_status(101).with_stderr(
19041919
"\
19051920
[ERROR] failed to parse manifest at `[..]`
@@ -1919,6 +1934,8 @@ fn namespaced_implicit_non_optional() {
19191934
.file(
19201935
"Cargo.toml",
19211936
r#"
1937+
cargo-features = ["namespaced-features"]
1938+
19221939
[project]
19231940
name = "foo"
19241941
version = "0.0.1"
@@ -1936,7 +1953,7 @@ fn namespaced_implicit_non_optional() {
19361953
.build();
19371954

19381955
assert_that(
1939-
p.cargo("build"),
1956+
p.cargo("build").masquerade_as_nightly_cargo(),
19401957
execs().with_status(101).with_stderr(
19411958
"\
19421959
[ERROR] failed to parse manifest at `[..]`
@@ -1955,6 +1972,8 @@ fn namespaced_same_name() {
19551972
.file(
19561973
"Cargo.toml",
19571974
r#"
1975+
cargo-features = ["namespaced-features"]
1976+
19581977
[project]
19591978
name = "foo"
19601979
version = "0.0.1"
@@ -1971,5 +1990,8 @@ fn namespaced_same_name() {
19711990
.file("src/main.rs", "fn main() {}")
19721991
.build();
19731992

1974-
assert_that(p.cargo("build"), execs().with_status(0));
1993+
assert_that(
1994+
p.cargo("build").masquerade_as_nightly_cargo(),
1995+
execs().with_status(0),
1996+
);
19751997
}

0 commit comments

Comments
 (0)