rust-lang / rust-lang/rust-clippy

clippy::multiple_crate_versions ignores selected dependency crate features (no-default-features)

Open
#16,440 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug I-false-positive
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Summary

The clippy::multiple_crate_versions lint incorrectly warns about dependency "conflicts" for crates that are disabled using --no-default-features. This is a false positive and not very helpful, as these dependencies are not even downloaded or compiled.

Specifics

The lint claims that my crate's dependencies use multiple versions of thiserror, getrandom as well as some Windows sys crates.
However, I use default-features = false on my dependencies and do not use any Windows related features.

Therefore, this lint is a false positive, since these dependencies are not truly being used. This can be confirmed by running cargo tree, which neither shows anything about thiserror, nor about getrandom, nor about windows_*.

Lint Name

multiple_crate_versions

Reproducer
  1. Visit https://github.com/BioTomateDE/.BugClippyMultipleCrateVersions/
  2. Clone the repository
  3. Run cargo clippy - Should show multiple_crate_versions warnings
  4. Run cargo tree - None of the mentioned crates are listed
  5. Run cargo tree | grep thiserror - Empty output
  6. Run cargo tree | grep getrandom - Empty output
  7. Run cargo tree | grep windows - Empty output

More generically:

  1. Use default-features = false on one or more dependencies
  2. Have multiple dependencies which themselves both depend on the same crate (somewhere down the graph), but on a different version
  3. Unprofit
Version
rustc 1.92.0 (ded5c06cf 2025-12-08)
binary: rustc
commit-hash: ded5c06cf21d2b93bffd5d884aa6e96934ee4234
commit-date: 2025-12-08
host: x86_64-unknown-linux-gnu
release: 1.92.0
LLVM version: 21.1.3
Additional Labels

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproducer, run cargo clippy, and compare its multiple_crate_versions warnings with cargo tree output. Trace how the lint handles dependency features, then verify that crates disabled by default-features = false no longer produce warnings while genuinely used multiple versions still do.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.