Skip to content

False positive regression for unused_crate_dependencies #147069

Open

Description

@robertbastian

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 error

This crate is used, so it's regression, not a bug fix.

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 26, 2025
  2. lukaslueg commented on Sep 26, 2025

    @lukaslueg
    Contributor

    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

  3. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Sep 26, 2025
  4. self-assigned this
    on Sep 29, 2025
  5. added
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Oct 5, 2025
  6. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Oct 5, 2025
  7. apiraino commented on Oct 6, 2025

    @apiraino
    Contributor

    Assigning priority (discussion on Zulip).

    @rustbot label -I-prioritize +P-medium

  8. added and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Oct 6, 2025
  9. petrochenkov commented on Oct 9, 2025

    @petrochenkov
    Contributor

    This crate is used, so it's regression, not a bug fix.

    From rustc's point of view --extern icu_locale_core is indeed unused and can be removed, because the name icu_locale_core is already imported by use icu_provider::prelude::*; at the points of use.

    Removing icu_locale_core from components\properties\Cargo.toml however results in compilation errors, I guess it messes up the set of cargo features enabled for the crate, somehow?
    (icu_locale_core/serde and icu_locale_core/databake do not get propagated?)

    It's one more example (together with #95513, #101334 and couple of other issues) showing why unused_crate_dependencies cannot work reliably at compiler level and needs build system support.
    That's why the unused_crate_dependencies lint is disabled by default and why --json unused-externs/--json unused-externs-silent consumed by build tools exist as a better replacement.

  10. removed their assignment
    on Oct 9, 2025
  11. robertbastian commented on Oct 9, 2025

    @robertbastian
    ContributorAuthor

    Yeah it uses the icu_locale_core/zerovec feature.

  12. added a commit that references this issue on Oct 9, 2025
  13. added this to the 1.91.0 milestone on Oct 24, 2025
  14. added
    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
    and removed on Dec 5, 2025
  15. epage commented on Apr 22, 2026

    @epage
    Contributor

    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_dependencies

    If 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.ignore field but I'm exploring alternatives in rust-lang/rfcs#3920.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.L-false-positiveLint: False positive (should not have fired).L-unused_crate_dependenciesLint: unused_crate_dependenciesP-mediumMedium priorityT-compilerRelevant 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.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions