Skip to content

Commit 2eec0a2

Browse files
committed
test to reproduce unused_crate_deps warning with -Zbuild-std
1 parent 6cea00c commit 2eec0a2

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

tests/build-std/main.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,55 @@ fn test_proc_macro() {
438438
.run();
439439
}
440440

441+
#[cargo_test(build_std_real)]
442+
fn build_std_does_not_warn_about_implicit_std_deps() {
443+
let p = project()
444+
.file(
445+
"Cargo.toml",
446+
r#"
447+
[package]
448+
name = "buildstd_test"
449+
version = "0.1.0"
450+
edition = "2021"
451+
452+
[dependencies]
453+
bar = { path = "bar" }
454+
"#,
455+
)
456+
.file("src/main.rs", "fn main() {}")
457+
.file(
458+
"bar/Cargo.toml",
459+
r#"
460+
[package]
461+
name = "bar"
462+
version = "0.1.0"
463+
edition = "2021"
464+
"#,
465+
)
466+
.file("bar/src/lib.rs", "")
467+
.build();
468+
469+
p.cargo("build")
470+
.build_std()
471+
.target_host()
472+
.env("RUSTFLAGS", "-W unused-crate-dependencies")
473+
.with_stderr_data(
474+
str![[r#"
475+
[WARNING] extern crate `alloc` is unused in crate `bar`
476+
[WARNING] extern crate `alloc` is unused in crate `buildstd_test`
477+
[WARNING] extern crate `bar` is unused in crate `buildstd_test`
478+
[WARNING] extern crate `compiler_builtins` is unused in crate `buildstd_test`
479+
[WARNING] extern crate `core` is unused in crate `buildstd_test`
480+
[WARNING] extern crate `proc_macro` is unused in crate `buildstd_test`
481+
[WARNING] `buildstd_test` (bin "buildstd_test") generated 5 warnings
482+
...
483+
484+
"#]]
485+
.unordered(),
486+
)
487+
.run();
488+
}
489+
441490
#[cargo_test(build_std_real)]
442491
fn default_features_still_included_with_extra_build_std_features() {
443492
// This is a regression test to ensure when adding extra `build-std-features`,

0 commit comments

Comments
 (0)