Skip to content

Commit 85cc994

Browse files
committed
test: Show bad error for dep_name/feature_name on 2024
1 parent 6db2864 commit 85cc994

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

tests/testsuite/features.rs

+57
Original file line numberDiff line numberDiff line change
@@ -1847,6 +1847,63 @@ fn features_option_given_twice() {
18471847
p.cargo("check --features a --features b").run();
18481848
}
18491849

1850+
#[cargo_test(nightly, reason = "edition2024 is not stable")]
1851+
fn strong_dep_feature_edition2024() {
1852+
let p = project()
1853+
.file(
1854+
"Cargo.toml",
1855+
r#"
1856+
cargo-features = ["edition2024"]
1857+
[package]
1858+
name = "foo"
1859+
version = "0.1.0"
1860+
edition = "2024"
1861+
1862+
[features]
1863+
optional_dep = ["optional_dep/foo"]
1864+
1865+
[dependencies]
1866+
optional_dep = { path = "optional_dep", optional = true }
1867+
"#,
1868+
)
1869+
.file(
1870+
"src/main.rs",
1871+
r#"
1872+
fn main() {}
1873+
"#,
1874+
)
1875+
.file(
1876+
"optional_dep/Cargo.toml",
1877+
r#"
1878+
[package]
1879+
name = "optional_dep"
1880+
[features]
1881+
foo = []
1882+
"#,
1883+
)
1884+
.file(
1885+
"optional_dep/src/lib.rs",
1886+
r#"
1887+
"#,
1888+
)
1889+
.build();
1890+
1891+
p.cargo("metadata")
1892+
.masquerade_as_nightly_cargo(&["edition2024"])
1893+
.with_status(101)
1894+
.with_stderr_data(str![[r#"
1895+
[ERROR] feature `optional_dep` includes `optional_dep/foo`, but `optional_dep` is not a dependency
1896+
--> Cargo.toml:9:32
1897+
|
1898+
9 | optional_dep = ["optional_dep/foo"]
1899+
| ^^^^^^^^^^^^^^^^^^^^
1900+
|
1901+
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
1902+
1903+
"#]])
1904+
.run();
1905+
}
1906+
18501907
#[cargo_test]
18511908
fn multi_multi_features() {
18521909
let p = project()

0 commit comments

Comments
 (0)