Skip to content

Commit 3410354

Browse files
committed
test: Add test for weak optional feature in edition2024
1 parent 34a6a87 commit 3410354

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

tests/testsuite/lints/unused_optional_dependencies.rs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,72 @@ warning: unused optional dependency
157157
)
158158
.run();
159159
}
160+
161+
#[cargo_test(nightly, reason = "edition2024 is not stable")]
162+
fn inactive_weak_optional_dep() {
163+
Package::new("dep", "0.1.0").publish();
164+
let p = project()
165+
.file(
166+
"Cargo.toml",
167+
r#"
168+
cargo-features = ["edition2024"]
169+
[package]
170+
name = "foo"
171+
version = "0.1.0"
172+
edition = "2024"
173+
174+
[dependencies]
175+
176+
[features]
177+
feat = ["dep?/feat"]
178+
"#,
179+
)
180+
.file("src/lib.rs", "")
181+
.build();
182+
183+
p.cargo("check -Zcargo-lints")
184+
.masquerade_as_nightly_cargo(&["cargo-lints", "edition2024"])
185+
.with_status(101)
186+
.with_stderr(
187+
"\
188+
error: failed to parse manifest at `[ROOT]/foo/Cargo.toml`
189+
190+
Caused by:
191+
feature `feat` includes `dep?/feat`, but `dep` is not a dependency
192+
",
193+
)
194+
.run();
195+
196+
let p = project()
197+
.file(
198+
"Cargo.toml",
199+
r#"
200+
cargo-features = ["edition2024"]
201+
[package]
202+
name = "foo"
203+
version = "0.1.0"
204+
edition = "2024"
205+
206+
[dependencies]
207+
dep = { version = "0.1.0", optional = true }
208+
209+
[features]
210+
feat = ["dep?/feat"]
211+
"#,
212+
)
213+
.file("src/lib.rs", "")
214+
.build();
215+
216+
p.cargo("check -Zcargo-lints")
217+
.masquerade_as_nightly_cargo(&["cargo-lints", "edition2024"])
218+
.with_status(101)
219+
.with_stderr(
220+
"\
221+
error: failed to parse manifest at `[ROOT]/foo/Cargo.toml`
222+
223+
Caused by:
224+
feature `feat` includes `dep?/feat`, but `dep` is not a dependency
225+
",
226+
)
227+
.run();
228+
}

0 commit comments

Comments
 (0)