Repository navigation
False positive regression for unused_crate_dependencies #147069
Copy link
Copy link
Open
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.L-false-positiveLint: False positive (should not have fired).Lint: False positive (should not have fired).L-unused_crate_dependenciesLint: unused_crate_dependenciesLint: unused_crate_dependenciesP-mediumMedium priorityMedium priorityT-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.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Milestone
Description
In beta (1.91.0-beta.3 (24bb93c38 2025-09-10)), there is a false positive from the unused_crate_dependencies lint that does not happen on 1.90.
To reproduce:
- clone https://github.com/unicode-org/icu4x at
292384d6a04746164faee7d660e75a5c7ca2b89c RUSTFLAGS="-D unused_crate_dependencies" cargo check --all-features --manifest-path components/properties/Cargo.toml- ✅
RUSTFLAGS="-D unused_crate_dependencies" cargo +beta check --all-features --manifest-path components/properties/Cargo.toml
error: extern crate `icu_locale_core` is unused in crate `icu_properties`
--> components/properties/src/lib.rs:5:1
|
5 | //! Definitions of [Unicode Properties] and APIs for
| ^
|
= help: remove the dependency or add `use icu_locale_core as _;` to the crate root
= note: requested on the command line with `-D unused-crate-dependencies`
error: could not compile `icu_properties` (lib) due to 1 previous errorThis crate is used, so it's regression, not a bug fix.
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.L-false-positiveLint: False positive (should not have fired).Lint: False positive (should not have fired).L-unused_crate_dependenciesLint: unused_crate_dependenciesLint: unused_crate_dependenciesP-mediumMedium priorityMedium priorityT-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.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Activity
lukaslueg commentedon Sep 26, 2025
Bisects to #144793, cc @petrochenkov
searched nightlies: from nightly-2025-06-23 to nightly-2025-09-26
regressed nightly: nightly-2025-08-15
searched commit range: 3672a55...898aff7
regressed commit: 8e77954
apiraino commentedon Oct 6, 2025
Assigning priority (discussion on Zulip).
@rustbot label -I-prioritize +P-medium
Ignore tidy failure in beta, nightly (#7044)
petrochenkov commentedon Oct 9, 2025
From rustc's point of view
--extern icu_locale_coreis indeed unused and can be removed, because the nameicu_locale_coreis already imported byuse icu_provider::prelude::*;at the points of use.Removing
icu_locale_corefromcomponents\properties\Cargo.tomlhowever results in compilation errors, I guess it messes up the set of cargo features enabled for the crate, somehow?(
icu_locale_core/serdeandicu_locale_core/databakedo not get propagated?)It's one more example (together with #95513, #101334 and couple of other issues) showing why
unused_crate_dependenciescannot work reliably at compiler level and needs build system support.That's why the
unused_crate_dependencieslint is disabled by default and why--json unused-externs/--json unused-externs-silentconsumed by build tools exist as a better replacement.robertbastian commentedon Oct 9, 2025
Yeah it uses the
icu_locale_core/zerovecfeature.Fix unused_crate_dependencies (#7058)
Work around unused-crate-dependencies in hphp/hack/src/utils/test
epage commentedon Apr 22, 2026
As part of https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#lintscargo, Cargo has a lint that wraps
unused_crate_dependencies, see https://doc.rust-lang.org/nightly/cargo/reference/lints.html#unused_dependenciesIf this is really for a feature activation, that is something we are still investigating how we want to handle. We have a
lints.cargo.unused_dependencies.ignorefield but I'm exploring alternatives in rust-lang/rfcs#3920.