-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
mkdir /tmp/repro
cd /tmp/repro
tee -a Cargo.toml > /dev/null <<EOF
[lints.rust]
unused_crate_dependencies = { level = "warn", priority = -1 }
unused_extern_crates = { level = "warn", priority = -1 }
EOF
cargo +nightly -Z build-std buildCurrent output
$ cargo +nightly -Z build-std build
Compiling compiler_builtins v0.1.160 (/home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins)
Compiling core v0.0.0 (/home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
Compiling libc v0.2.178
Compiling object v0.37.3
Compiling std v0.0.0 (/home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std)
Compiling rustc-std-workspace-core v1.99.0 (/home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
Compiling alloc v0.0.0 (/home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc)
Compiling adler2 v2.0.1
Compiling memchr v2.7.6
Compiling rustc-demangle v0.1.27
Compiling panic_abort v0.0.0 (/home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/panic_abort)
Compiling cfg-if v1.0.4
Compiling rustc-literal-escaper v0.0.7
Compiling unwind v0.0.0 (/home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/unwind)
Compiling rustc-std-workspace-alloc v1.99.0 (/home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-alloc)
Compiling panic_unwind v0.0.0 (/home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/panic_unwind)
Compiling gimli v0.32.3
Compiling std_detect v0.1.5 (/home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std_detect)
Compiling miniz_oxide v0.8.9
Compiling hashbrown v0.16.1
Compiling addr2line v0.25.1
Compiling proc_macro v0.0.0 (/home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro)
Compiling repro v0.1.0 (/tmp/repro)
warning: extern crate `alloc` is unused in crate `repro`
|
= help: remove the dependency or add `use alloc as _;` to the crate root
= note: requested on the command line with `-W unused-crate-dependencies`
warning: extern crate `compiler_builtins` is unused in crate `repro`
|
= help: remove the dependency or add `use compiler_builtins as _;` to the crate root
warning: extern crate `core` is unused in crate `repro`
|
= help: remove the dependency or add `use core as _;` to the crate root
warning: extern crate `proc_macro` is unused in crate `repro`
|
= help: remove the dependency or add `use proc_macro as _;` to the crate root
warning: `repro` (bin "repro") generated 4 warnings
Finished `dev` profile [unoptimized + debuginfo] target(s) in 15.77sDesired output
No Diags `unused_crate_dependencies`/`unused_extern_crates` should be issued.Rationale and extra context
Those crates aren't listed in Cargo.toml, they were implicitly added by -Z build-std,
therefore it would be great if they weren't diagnosed.
Other cases
Rust Version
$ /home/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --version --verbose
rustc 1.95.0-nightly (7057231bd 2026-02-11)
binary: rustc
commit-hash: 7057231bd78d6c7893f905ea1832365d4c5efe17
commit-date: 2026-02-11
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 22.1.0Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.