rust-lang / rust-lang/rust-clippy

`multiple_crate_versions` false negative in source repo but not as dependency

Open
#15,643 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Summary

In the crate nsys-enet 0.1.0 I have:

[lints.clippy]
multiple-crate-versions = "warn"

And because of a dependency, both "num-traits 0.1.43" and "num-traits 0.2.19" are in the dependency graph. (I have replaced the dependency in v0.2.0 so this only applies to v0.1.0 of the crate, but I have encountered the same issue with other crates of mine with more dependencies).

However when running cargo clippy no warning is emitted. But if I create a new crate and add nsys-enet as a dependency and enable the multiple_crate_versions lint, then a warning is emitted:

warning: multiple versions for dependency `num-traits`: 0.1.43, 0.2.19
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions
  = note: requested on the command line with `-W clippy::multiple-crate-versions`

I also encounter the same issue with the nsys-gl-utils crate, with a larger number of dependencies.

Version info:

rustc 1.91.0-nightly (9c27f27ea 2025-09-08)
cargo 1.91.0-nightly (761c4658d 2025-09-04)
clippy 0.1.91 (9c27f27ea3 2025-09-08)
Lint Name

multiple_crate_versions

Reproducer

I tried this code:

git clone https://github.com/spearman/enet-rs && cd enet-rs && git checkout v0.1.0 && cargo clippy

I expected to see this happen:

warning: multiple versions for dependency `num-traits`: 0.1.43, 0.2.19
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions
  = note: requested on the command line with `-W clippy::multiple-crate-versions`

Instead, this happened:

[nothing]

Version
rustc 1.91.0-nightly (9c27f27ea 2025-09-08)
binary: rustc
commit-hash: 9c27f27ea3bab79a2fec827ef3ae0009959d60f4
commit-date: 2025-09-08
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.0

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

Clone the enet-rs repository, check out v0.1.0, and run cargo clippy with the multiple_crate_versions lint enabled. Compare the source crate's dependency graph with the dependency-use case in the report, then make the lint emit the expected warning for both num-traits versions and verify the result with the reproducer.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.