Skip to content

Commit eb7f357

Browse files
committed
test to reproduce unused_crate_deps warning with -Zbuild-std
1 parent f298b8c commit eb7f357

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

tests/build-std/main.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,48 @@ fn host_proc_macro() {
288288
.run();
289289
}
290290

291+
#[cargo_test(build_std_real)]
292+
fn build_std_does_not_warn_about_implicit_std_deps() {
293+
let p = project()
294+
.file(
295+
"Cargo.toml",
296+
r#"
297+
[package]
298+
name = "buildstd_test"
299+
version = "0.1.0"
300+
edition = "2021"
301+
302+
[dependencies]
303+
bar = { path = "bar" }
304+
"#,
305+
)
306+
.file("src/main.rs", "fn main() {}")
307+
.file(
308+
"bar/Cargo.toml",
309+
r#"
310+
[package]
311+
name = "bar"
312+
version = "0.1.0"
313+
edition = "2021"
314+
"#,
315+
)
316+
.file("bar/src/lib.rs", "")
317+
.build();
318+
319+
p.cargo("build")
320+
.build_std()
321+
.target_host()
322+
.env("RUSTFLAGS", "-W unused-crate-dependencies")
323+
// correctly warns
324+
.with_stderr_contains("[WARNING] extern crate `bar` is unused in crate `buildstd_test`")
325+
// should NOT warn but currently do
326+
.with_stderr_contains("[WARNING] extern crate `core` is unused [..]")
327+
.with_stderr_contains("[WARNING] extern crate `alloc` is unused [..]")
328+
.with_stderr_contains("[WARNING] extern crate `compiler_builtins` is unused [..]")
329+
.with_stderr_contains("[WARNING] extern crate `proc_macro` is unused [..]")
330+
.with_stderr_contains("[WARNING] extern crate `panic_unwind` is unused [..]")
331+
.run();
332+
}
291333
#[cargo_test(build_std_real)]
292334
fn cross_custom() {
293335
let p = project()

0 commit comments

Comments
 (0)